*新闻详情页*/>
一、难题
二、处理方法
1.clear:both
在最终一个波动原素后边加上特性为clear:both;的原素。
<style> div.parent>div.fl{ float: left; width: 200px; height: 200px; margin-right: 20px; border: 1px solid red; } .clear{ clear: both; } </style> <div class="parent"> <div class="fl">1</div> <div class="fl">2</div> <div class="fl">3</div> <div class="fl">4</div> <div class="clear">5</div> </div>
给父原素加上clear:both;特性的:after伪原素。
<style> div.parent>div.fl{ float: left; width: 200px; height: 200px; margin-right: 20px; border: 1px solid red; } .clear:after{ content: ''; display: block; clear: both; } </style> <div class="parent clear"> <div class="fl">1</div> <div class="fl">2</div> <div class="fl">3</div> <div class="fl">4</div> </div>
留意:伪原素默认设置是内联水准,因此依靠伪原素时要设定特性display: block;。
2.overflow:auto / overflow: hidden
<style> div.parent{ overflow: auto; /*overflow: hidden;还可以*/ } div.parent>div.fl{ float: left; width: 200px; height: 200px; margin-right: 20px; border: 1px solid red; } </style> <div class="parent"> <div class="fl">1</div> <div class="fl">2</div> <div class="fl">3</div> <div class="fl">4</div> </div>
3.波动父级原素
<style> div.parent{ float: left; } div.parent>div.fl{ float: left; width: 200px; height: 200px; margin-right: 20px; border: 1px solid red; } </style> <div class="parent"> <div class="fl">1</div> <div class="fl">2</div> <div class="fl">3</div> <div class="fl">4</div> </div>
留意:一般无需这一方式,会造成父级原素排版设计难题。
到此这篇有关详细说明波动原素造成的难题调解决方法的文章内容就详细介绍到这了,大量有关波动原素造成难题內容请检索脚本制作之家之前的文章内容或再次访问下边的有关文章内容,期待大伙儿之后多多的适用脚本制作之家!
Copyright © 2002-2020 h5互动游戏_微信h5怎么制作_h5转盘抽奖_h5测试制作_凡科H5 版权所有 (网站地图) 粤ICP备10235580号