欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript ie6兼容position:fixed實(shí)現(xiàn)思路

 更新時(shí)間:2013年04月01日 10:20:20   作者:  
positon:fixed 讓HTML元素脫離文檔流固定在瀏覽器的某個(gè)位置,由于網(wǎng)頁(yè)中類似這樣的元素很多,所以本文的出現(xiàn)是很有必要的了,接下為大家介紹下javascript如何實(shí)現(xiàn)ie6下的position:fixed
positon:fixed 讓HTML元素脫離文檔流固定在瀏覽器的某個(gè)位置
網(wǎng)頁(yè)中經(jīng)常會(huì)有浮動(dòng)的導(dǎo)航條會(huì)用到這種定位模式,但是ie6下并不兼容這種定位
浮動(dòng)導(dǎo)航條的樣式,重要的是position:fixed;bottom:60px;(浮動(dòng)導(dǎo)航底部距離窗口底部60px)
復(fù)制代碼 代碼如下:

.floating_9677{position:fixed; z-index:961; bottom:60px;}

ie6下positon:fixed不起作用,只能靠js來(lái)實(shí)現(xiàn)了,首先在ie6下需要將position設(shè)置為absolute
復(fù)制代碼 代碼如下:

position:fixed;bottom:60px;_position:abosulte;

給浮動(dòng)元素加一個(gè)屬性標(biāo)識(shí),js通過這個(gè)屬性能找到這些浮動(dòng)元素。tag="floatNavigator"
工作中浮動(dòng)導(dǎo)航條主要通過top或者bottom來(lái)定位。
復(fù)制代碼 代碼如下:

//ie6兼容position:fixed
function fixedPositionCompatibility(){
//判斷是否ie6瀏覽器
if( $.browser.msie || parseInt($.browser.version,10) <= 6){
var vavigators = $("[tag='floatNavigator']");
if(!navigators.length)return;
//判斷每個(gè)浮層是靠頂部固定還是底部固定
$.each(navigators, function(){
this.top = $(this).css("top");
this.bottom = $(this).css("bottom");
this.isTop = this.top == "auto" ? false : true;
});
window.attachEvent("onscroll", function(){
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
$.each(navigators, function(){
this.style.top = this.isTop ? scrollTop + parseInt(this.top) + "px" : scrollTop + $(window).height() - $(this).outerHeight() - parseInt(this.bottom) + "px";
});
});
}
}

相關(guān)文章

最新評(píng)論