CSS-position:fixed兼容IE
阿新 • • 發佈:2017-11-29
scrip 保持 res document ie6 div position -i 圖片
一般要固定容器的話,可以直接用position:fixed,但不兼容IE
要兼容IE,頁很簡單,不需要JavaScript代碼。
!!!------CSS:
<style>
*{margin:0;padding:0;}
#div1{width:100%;height:70px;background:#ccc;position:fixed;right:0;
/*ie6下樣式,加下劃線表示只針對ie6 的hack */
_position:absolute;/* 把導航欄位置定義為絕對位置 關鍵*/
_top:expression(documentElement.scrollTop + "px"); /* 把導航欄位置放在瀏覽器垂直滾動條的頂端 關鍵 */
z-index:9999; /* 讓導航欄浮在網頁的高層位置,遇到flash和圖片時候也能始終保持最外層 */}
body{height:2000px;}
/**/
</style>
!!!------HTML:
<body>
<div id="div1"></div>
</body>
CSS-position:fixed兼容IE