完美解決IE6中fixed抖動問題的方法

咱們能夠經過position:fixed來實現元素的固定效果,如網頁中底部的"回到頂部菜單",底部的toolbar,對聯廣告等等,惋惜fixed屬性在IE6及如下是不支持的。一般的做法,咱們用JS或者IE表達式來達到這個效果。

如:html

.fixed{ position: fixed; _position: absolute; _top: expression(eval(document.documentElement.scrollTop)); 
   }

惋惜,又遇到一個問題,頁面滾動的時候,會出現抖動現象.express

若是解決呢?url

無心中發現咱們momo社區的左側導航欄在IE6下頁面滾動時候竟然不抖動,看了下CSS,和上面的表達式沒有任何區別呀。。。spa

因而對HTML和CSS進行最簡化刪除,最終發現,原來是body屬性中設置了背景圖片恰好解決了這個抖動的問題!code

body中設置了一個樣式:htm

body{ background: url(body.jpg) fixed; 
   }

上網搜了下,竟然已經有人這樣經過這個辦法解決,順便還找到了另外一個解決方法,總結以下:blog

方法1圖片

.fixed{ position: fixed; _position: absolute; _top: expression(eval(document.documentElement.scrollTop));} html{ _text-overflow:ellipsis; 
   }

方法2ip

.fixed{ position: fixed; _position: absolute; _top: expression(eval(document.documentElement.scrollTop)); 
   } html { _background: url(xx.jpg) fixed; /* 文件不存在亦能夠,隨便命名 */
   }
相關文章
相關標籤/搜索