天天看点

纯css修正IE6不支持position:fixed的bug

css:

* {

margin : 0 ;

}

html, body {

height : 100% ;

overflow : auto ;

}

.wrapper {

position : relative ;

width : 100% ;

height : 100% ;

overflow : auto ;

}

.box {

position : fixed ;

left : 10px ;

top : 180px ;

}

* html .box {

position : absolute ;

}

html:

< html >

< head >

< link rel ="stylesheet" href ="layout.css" ... />

</ head >

< body >

< div class ="wrapper" >

< p > All of your website content should be here. </ p >

</ div >

< div class ="box" >

< p > This box is fixed. </ p >

</ div >

</ body >

</ html >

上面的代码的关键代码是:

html,body{overflow:auto; height:100%;};

* html .box {position: absolute; };

加上这两段代码就能修复bug。

原文链接:http://ryanfait.com/resources/fixed-positioning-in-internet-explorer/

转载于:https://www.cnblogs.com/ginowang42/archive/2011/04/11/2012183.html