当前位置: 移动技术网 > IT编程>网页制作>CSS > float引起层飘出父层的解决方法

float引起层飘出父层的解决方法

2017年12月08日  | 移动技术网IT编程  | 我要评论
1.加clear空div
.clearfix:after {
content: “.”; display: block;
height: 0;
clear: both;
visibility: hidden;}
.clearfix {display: inline-block;}
/* hides from ie-mac \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}/* end hide from ie-mac */
.clearfix {
display: block;
margin: 0px;
clear: both;
padding: 0px;
visibility: hidden;
background-color:#666666;
border:0px none #ffffff;
}
.clearfix:after { height: 1px;}

使用方法:
在所有浮动层之后加上这个层
<div class=”clearfix”></div>

2.把背景层加浮动,但是这个方法会影响其他的div,有时候好用。

3.加 overflow 这个也有问题,会影响div的外观。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网