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://hxwzsj.com/article/gcgoeg.html">http://hxwzsj.com/article/gcgoeg.html</a>
        </div>
    </div>
    <div class="other">
        <h3>其他资讯</h3>
        <ul>
            <li>
                    <a href="/article/dijdsec.html">jquery判重 jquery判断是否有class</a>
                </li><li>
                    <a href="/article/dijdseh.html">mysql字母怎么排序 mysql 汉字排序</a>
                </li><li>
                    <a href="/article/dijdcch.html">mysql数据怎么停下来 mysql怎么保证数据不丢失</a>
                </li><li>
                    <a href="/article/dijdseg.html">mysql文件怎么存放 mysql的文件</a>
                </li><li>
                    <a href="/article/dijdsoi.html">linux命令怎么缩小 linux终端缩小</a>
                </li>        </ul>
    </div>
</div>
<div class="footer2">
    Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14 <br />友情链接:
    <a href="http://www.cdkjz.cn/fangan/response/" target="_blank">响应式网站设计方案 </a><a href="http://www.cxhljz.com/" target="_blank">网站设计制作 </a><a href="http://chengdu.cdcxhl.cn/qiye/" target="_blank">企业网站建设公司 </a><a href="http://m.cdcxhl.cn/mobile/" target="_blank">手机网站设计 </a><a href="https://www.cdxwcx.com/wangzhan/pinpai.html" target="_blank">高端品牌网站建设 </a><a href="http://www.cqcxhl.com/" target="_blank">重庆网站建设 </a><a href="http://www.cdxwcx.cn/bj/" target="_blank">网站制作报价 </a><a href="http://chengdu.cdcxhl.com/dingzhi/" target="_blank">定制网站建设 </a><a href="http://www.cdweb.net/" target="_blank">成都网站设计 </a><a href="http://chengdu.cdcxhl.cn/" target="_blank">成都网站建设 </a><a href="http://www.ybwzjz.com/" target="_blank">宜宾网站设计 </a><a href="http://m.cdxwcx.com/" target="_blank">成都网站建设公司 </a><a href="http://www.kswcd.com/" target="_blank">企业网站设计 </a><a href="http://chengdu.cdweb.net/" target="_blank">成都网站建设 </a><a href="https://www.cdcxhl.com/waimao.html" target="_blank">外贸网站建设 </a><a href="http://m.cdcxhl.com/" target="_blank">成都网站制作 </a><a href="http://m.cdcxhl.com/" target="_blank">成都网站制作 </a><a href="http://www.myzitong.com/" target="_blank">梓潼网站设计 </a><a href="http://chengdu.cdxwcx.cn/wangzhan/" target="_blank">企业网站设计 </a><a href="http://www.abwzjs.com/" target="_blank">阿坝网站设计 </a><a href="http://www.cxjianzhan.com/" target="_blank">成都网站建设公司 </a><a href="https://www.cdcxhl.com/xiangyingshi.html" 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=hxwzsj.com&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=hxwzsj.com&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>