大家知道 IE6 不支持 position:fixed;那么我们可以用 position:absolute 来模拟 position:fixed 的效果
先来看 CSS
-
- <style>
- *{
- padding:0; margin:0
- }
- html{
- _overflow:hidden/*IE6 重要!*/
- }
- body{
- _height:100%; _overflow:auto;/*IE6 重要!*/
- }
- .ie6fix{
- position:fixed; _position:absolute; width:500px; height:200px; background:red; top:0; left:0; z-index:999/*position:fixed VS position:absolute*/
- }
- p{
- height:50px
- }
- </style>
复制代码
fixed 元素的绝对位置是相对于 HTML 元素来说,滚动条是 body 元素的 - -|||;让 html 和 body 高度相同,其余的溢出隐藏
html 代码
-
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <p>1</p>
- <div class="ie6fix"></div>
复制代码
正文完