元素设置position:fixed属性后IE下宽度无法100%延伸

元素设置position:fixed属性后IE下宽度无法100%延伸

IE bug 出现条件:

1、div1设置position:fixed属性,并且想要width:100%的效果。

2、div2(下层元素)设置了宽度并居中。

解决方案:

.div1{left:0}即fixed层设置left值为0。

代码如下:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <title>test</title>
 5 <style>
 6 *{margin:0px;padding:0px}
 7 .div1{position:fixed;height:40px;background:#666;width:100%;color:#fff}
 8 .div2{width:980px;margin:0 auto}
 9 </style>
10 </head>
11 
12 <body>
13     <div class="test">
14         <div class="div1">元素设置position:fixed属性后IE下宽度无法100%延伸</div>
15         <div class="div2">div2设置了宽度</div>
16     </div>
17 </body>
18 </html>

 

posted on 2013-07-15 09:04  Cosimo  阅读(774)  评论(0编辑  收藏  举报

导航