<code id='85A95C7FD4'></code><style id='85A95C7FD4'></style>
    • <acronym id='85A95C7FD4'></acronym>
      <center id='85A95C7FD4'><center id='85A95C7FD4'><tfoot id='85A95C7FD4'></tfoot></center><abbr id='85A95C7FD4'><dir id='85A95C7FD4'><tfoot id='85A95C7FD4'></tfoot><noframes id='85A95C7FD4'>

    • <optgroup id='85A95C7FD4'><strike id='85A95C7FD4'><sup id='85A95C7FD4'></sup></strike><code id='85A95C7FD4'></code></optgroup>
        1. <b id='85A95C7FD4'><label id='85A95C7FD4'><select id='85A95C7FD4'><dt id='85A95C7FD4'><span id='85A95C7FD4'></span></dt></select></label></b><u id='85A95C7FD4'></u>
          <i id='85A95C7FD4'><strike id='85A95C7FD4'><tt id='85A95C7FD4'><pre id='85A95C7FD4'></pre></tt></strike></i>

          css如何清除pg麻巅峰国际app官方入口将胡了中几十万浮动clear与float

          2025-06-23 06:04:31 74995
          但是一旦浮动,块元素就没有必要转化啦。所以叫清浮动。浮动会对文档产生影响,但是有时希望内容能够撑开高度(比如内容不固定的时候)。

          清除浮动有很多种,元素就没有浮动了,

          二:br标签清除浮动(如下代码)

          <!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div><!--br标签自带的属性--><br clear="all"></div><div class="footer"></div></div></body></html>

          三:父元素设置overflow:hidden (如下代码)

          <!doctype html> <html> <head><meta charset="utf-8"> <title>MAOLAI博客</title> <link rel="stylesheet" href="reset.css"> <style> .main{overflow:hidden;} .main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;} .footer{width:620px;height:100px;background:red;} </style> </head> <body> <div class="wrap"> <div class="main"> <div>个人博客</div> <div>个人网站</div> </div> <div class="footer"></div> </div> </body> </html>

          四:父元素设置overflow:auto (如下代码)

          <!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main{overflow:auto;}.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>

          五:父元素浮动

          <!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main{float:left;}.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>

          效果:

          css如何清除浮动clear与float-图片3

          注释:使得与父元素相邻的元素的布局会受到影响(影响到了类名为footer的元素)。元素脱离文档流,主要是帮助pg麻将胡了中几十万<巅峰国际app官方入口/strong>大家理解哪一种清除浮动比较好,当然可以用别的标签;如果用行元素的话需要进行转化为块,它们是能够撑开外部div的高度的,如何进行选择清除浮动了?以下是清浮动的具体代码实现,

          六:父元素设置display:table

          <!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main{display:table;}.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>

          七:after 伪元素(不是伪类)

          <!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}.clearfix:after{clear:both;display:block;height:0;content:"200B";}.clearfix{*zoom:1;}</style></head><body><div class="wrap"><div class="main clearfix"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>

          注释:reset.css文件里面已经写好了after伪元素清浮动,不是同一概念)。

          (不要误解成把浮动清除了,

          大家都知道,

          一:空标签清浮动(如下代码)

          <!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main巅峰国际app官方入口 div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;backgrpg麻将胡了中几十万ound:red;}.clear{clear:both;height:0;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div><p class="clear"></p></div><div class="footer"></div></div></body></html>

          注释:上面用p标签进行空标签清浮动,父级div就相当于没有了内容(上面的例子中类名为main的高度为0了)。直接调用即可。这时是没有办法实现内容撑开高度的。此时需要进行清除浮动对布局造成的一系列影响,具体来看看会对文档产生什么影响?

          清除浮动后的效果:

          css如何清除浮动clear与float-图片1

          未清除浮动后的效果:

          css如何清除浮动clear与float-图片2

          实例代码(未清除浮动):

          <!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html

          解析:页面开发的时候可以为父级标签添加固定高度,辨析它们的优缺点而已。对于不浮动的元素来说,

          本文地址:http://lmywm.xny028cc.com/indeed/2025-06-22-22-55-53-1.html
          版权声明

          本文仅代表作者观点,不代表本站立场。
          本文系作者授权发表,未经许可,不得转载。

          热门标签

          全站热门

          圆形滚动404动画页面特效

          BTC Maintains $70K Despite Heightened GBTC Outflows, WIF Plummets Again (Market Watch)

          HTML5 WebGL 3D樱花飘落动画代码

          纤薄机身扫地新宠:科沃斯T50 PRO,水箱版1613元国补新低,体验升级更轻松

          wordpress(大前端)DUX主题v5.0模板下载

          荣耀手表Fit即将揭秘健康能量评估功能,萌宠表盘引爆5月28日,科技与时尚碰撞,你准备好了吗?

          大疆新款扫地机器人即将揭秘:别再忍耐,让尘埃落定!

          搜索引擎搜索关键词的标题与链接如何提取?