前段時(shí)間因?yàn)楣镜哪硞€(gè)項(xiàng)目需要用到底部固定元素在網(wǎng)頁中隨著瀏覽器滾動(dòng)而滾動(dòng),當(dāng)然用position:fixed這個(gè)屬性來做,可是問題來了,IE6.0下面不支持position:fixed這個(gè)屬性。 在網(wǎng)上查找資料,實(shí)踐,最終OK了, 石家莊網(wǎng)站建設(shè) 貼出來大家分享。 當(dāng)然,在IE
前段時(shí)間因?yàn)楣镜哪硞€(gè)項(xiàng)目需要用到底部固定元素在網(wǎng)頁中隨著瀏覽器滾動(dòng)而滾動(dòng),當(dāng)然用position:fixed這個(gè)屬性來做,可是問題來了,IE6.0下面不支持position:fixed這個(gè)屬性。
當(dāng)然,在IE6以上版本,火狐,谷歌等瀏覽器都是件容易的事情,直接用position:fixed這個(gè)屬性就可以搞定。如:
.top {position:fixed;bottom:auto;top:0px;} /* 頭部固定 */
.bottom {position:fixed;bottom:0px;top:auto;} /* 底部固定 */
.left {position:fixed;right:auto;left:0px;} /* 左側(cè)固定 */
.right{position:fixed;right:0px;left:auto;} /* 右側(cè)固定 */
但在IE6及以下版本這樣設(shè)置是沒用的,要設(shè)置成這樣:
body{background-image:url(about:blank);background-attachment:fixed;} /* 修正IE6振動(dòng)bug */
.top {position:absolute;bottom:auto;top:expression(evaldocument.documentElement.scrollTop));} /* IE6 頭部固定*/
.left{position:absolute;left:auto;right:expression(evaldocument.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));} /* IE6 右側(cè)固定 */
.right {position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));} /* IE6 右側(cè)固定 */
.bottom {position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));} /* IE6 底部固定 */