FF下div浮动导致外嵌套div不受控制的问题

1.如果内嵌div使用了浮动定位,在FF下(IE下可以显示撑大效果)将导致外部div不会受内部div影响而撑大,我在scriptygoddess找到了解决办法,就是使用一个清除格式的断点来使解决,原文内容:

When you float elements on your page they are taken out of the regular flow of your document. ie. they don't have width and heights when they are interacting with other elements. You can always add a break and clear after the 2 floated divs, and they will then make the container stretch in height to contain them eg.

< div id = " container " >
< div id = " float1 " >  sidebar  </ div >
< div id = " float2 " >  main text  </ div >
<br clear="all" />
</ div >  


 2.清除DIV浮动-使用:after (http://www.blueidea.com/tech/web/2005/3065.asp)

:after(伪对象)--设置在对象后发生的内容,通常和content配合使用,IE不支持此伪对象,非Ie 浏览器支持,所以并不影响到IE/WIN浏览器。
CSS

 

.wrapfix:after  {
    content: 
"."
    display: block;
    height: 
0
    clear: both; 
    visibility: hidden;
}
 

 

设display:block;应用到:after 元素,因为display的默认值是"inline", 不能收到clear的特性,同时将清除容器的高度设为零,height:0;,可见度为隐藏.这是没有清除过浮动的.非Ie 浏览器看不到wrap的背景和边框.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值