clear属性在CSS中的作用

本篇内容介绍了“clear属性在CSS中的作用”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

成都创新互联公司-专业网站定制、快速模板网站建设、高性价比兴平网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式兴平网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖兴平地区。费用合理售后完善,10年实体公司更值得信赖。

在CSS中clear属性妙用

在DIV+CSS设计网页中,经常需要设置多个DIV并列排列,往往是使用float:left或float:right来实现,但问题出现了,当前面并列的多个DIV总宽度不足100%,下面的的DIV就很可能向上提,和上一行的并列的DIV在同一行,这不是我们想要的结果。使用Clear属性正好可以解决这一问题,下面引用帮助的介绍:

CSS clear属性

Imageandtextelementsthatappearinanotherel  ementarecalledfloatingelements.  Theclearpropertysetsthesideso  fanelementwhereotherfloatingelementsarenotallowed.

图片和文字元素出现在另外元素中,那么它们(图片和文字)可称为浮动元素(floatingelement)。使用clear属性可以让元素边上不出现其它浮动元素。

Note:Thispropertydoesnotalwaysworkasexpectedifitisusedalongwiththe"float"property.
注意:当这个属性随着"float"属性一起使用的话,那么结果可能会不尽如人意

Inherited:No

◆继承性:无

◆可用值

clear属性在CSS中的作用

举例

    无标题文档title> <styletypestyletype="text/css"> .LeftText{  margin:3px;  float:left;  height:180px;  width:170px;  border:1pxsolid#B1D1CE;  background-color:#F3F3F3;  }   .FootText{  height:180px;  }   .Clear  {  clear:both;  }  style> head>  <body> <divclassdivclass="LeftText">区块1div> <divclassdivclass="LeftText">区块2div> <divclassdivclass="Clear">div> <divclassdivclass="FootText">区块3div> body> html></pre><p>◆代码说明:</p><p>如果没有Clear这一层,“区块3”会紧接区块2并列在同一行。</p><p>加了Clear这一层后,会把上面的浮动DIV的影响清除,使其不至影响下面DIV的布局</p><p>“clear属性在CSS中的作用”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!</p>            
            
                        <br>
            网站标题:clear属性在CSS中的作用            <br>
            浏览路径:<a href="http://csruizhi.cn/article/gcgoeg.html">http://csruizhi.cn/article/gcgoeg.html</a>
        </div>
    </div>
    <div class="other">
        <h3>其他资讯</h3>
        <ul>
            <li>
                    <a href="/article/dshjhog.html">调用平均函数的c语言程序 调用函数求平均数</a>
                </li><li>
                    <a href="/article/dshjhoc.html">帝国cmsmurl 帝国cmsmoretag插件</a>
                </li><li>
                    <a href="/article/dshjphi.html">域名注销但没公章怎么处理 域名注销但没公章怎么处理掉</a>
                </li><li>
                    <a href="/article/dshjhoe.html">关于sap系统当前日期的信息</a>
                </li><li>
                    <a href="/article/dshjpjh.html">sap系统状态是什么意思的简单介绍</a>
                </li>        </ul>
    </div>
</div>
<div class="footer2">
    Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号 <br />友情链接:
    <a href="https://www.cdcxhl.com/" target="_blank">成都网站建设公司 </a><a href="http://www.cdxtjz.com/" target="_blank">网站制作 </a><a href="http://m.cdxwcx.com/" target="_blank">成都网站建设 </a><a href="http://chengdu.kswsj.cn/" target="_blank">高端网站设计推广 </a><a href="http://www.cdwuji.cn/" target="_blank">成都网站建设 </a><a href="https://www.cdcxhl.com/waimao.html" target="_blank">外贸网站建设 </a><a href="http://www.cqcxhl.com/" target="_blank">重庆网站设计 </a><a href="http://www.kswcd.cn/serve/" target="_blank">专业网站设计 </a><a href="http://www.kswsj.com/" target="_blank">成都网站建设 </a><a href="http://m.cdcxhl.cn/dingzhi/" target="_blank">定制网站制作 </a><a href="http://chengdu.cdcxhl.cn/dingzhi/" target="_blank">成都定制网站建设 </a><a href="https://www.cdxwcx.com/" target="_blank">成都网站建设公司 </a><a href="http://www.scyanting.com/" target="_blank">盐亭网站设计 </a><a href="http://www.cxhljz.com/" target="_blank">成都做网站建设公司 </a><a href="https://www.cdcxhl.com/qiye.html" target="_blank">企业网站建设 </a><a href="http://www.cdxwcx.cn/" target="_blank">成都网站制作 </a><a href="http://chengdu.cdcxhl.com/" target="_blank">营销型网站建设 </a><a href="http://www.cxhljz.cn/" target="_blank">成都网站建设 </a><a href="http://www.cxjianzhan.com/" target="_blank">成都网站制作 </a><a href="http://www.kswsj.com/" target="_blank">成都网站设计 </a><a href="http://www.jywzsj.com/" target="_blank">成都网站设计 </a><a href="http://chengdu.cdcxhl.cn/jianshe/" target="_blank">成都网站建设公司 </a></div>

</body>
</html>
<script src="/Public/Home/js/wow.min.js"></script>
<script>
    if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
        new WOW().init();
    };
</script>
<div class="sidebar">
    <ul>
        <li><a href="http://wpa.qq.com/msgrd?v=3&uin=244261566&site=www.csruizhi.cn&menu=yes" target="_blank"><img src="/Public/Home/images/right_qq.png" /></a></li>
        <li><a href="http://wpa.qq.com/msgrd?v=3&uin=1683211881&site=www.csruizhi.cn&menu=yes" target="_blank"><img src="/Public/Home/images/qq.png" /></a></li>
        <li class="tel"><a href="tel:028-86922220"><img src="/Public/Home/images/right_tel.png" /></a></li>
        <div class="wx">
            <span class="weixin"><img src="/Public/Home/images/weixin.jpg"><br> 微信扫一扫在线咨询</span>
        </div>
        <li><a class="fx" href="#hero"><img src="/Public/Home/images/right_up.png" /></a></li>
    </ul>
</div>
<script type="text/javascript">
    $(function () {
        $('.sidebar .fx').click(function () {
            $('html,body').animate({
                scrollTop: '0px'
            }, 800);
        });
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#fancybox-manual-b").click(function () {
            $.fancybox.open({
                href: 'map.html',
                type: 'iframe',
                padding: 5
            });
        })
    });
</script>
<script>
    $(".con img").each(function(){
        var src = $(this).attr("src");    //获取图片地址
        var str=new RegExp("http");
        var result=str.test(src);
        if(result==false){
            var url = "https://www.cdcxhl.com"+src;    //绝对路径
            $(this).attr("src",url);
        }
    });
    window.onload=function(){
        document.oncontextmenu=function(){
            return false;
        }
    }
</script>