javascript实现ie6兼容position:fixed
2014-08-20 00:20
537 查看
positon:fixed 让HTML元素脱离文档流固定在浏览器的某个位置
网页中经常会有浮动的导航条会用到这种定位模式,但是ie6下并不兼容这种定位
浮动导航条的样式,重要的是position:fixed;bottom:60px;(浮动导航底部距离窗口底部60px)
.floating_9677{position:fixed; z-index:961; bottom:60px;}
ie6下positon:fixed不起作用,只能靠js来实现了,首先在ie6下需要将position设置为absolute
position:fixed;bottom:60px;_position:abosulte;
给浮动元素加一个属性标识,js通过这个属性能找到这些浮动元素。tag="floatNavigator"
工作中浮动导航条主要通过top或者bottom来定位。
//ie6兼容position:fixed
function fixedPositionCompatibility(){
//判断是否ie6浏览器
if( $.browser.msie
|| parseInt($.browser.version,10)
<= 6){
var vavigators = ("[tag=′floatNavigator′]");if(!navigators.length)return;//判断每个浮层是靠顶部固定还是底部固定.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";
});
});
}
}
网页中经常会有浮动的导航条会用到这种定位模式,但是ie6下并不兼容这种定位
浮动导航条的样式,重要的是position:fixed;bottom:60px;(浮动导航底部距离窗口底部60px)
.floating_9677{position:fixed; z-index:961; bottom:60px;}
ie6下positon:fixed不起作用,只能靠js来实现了,首先在ie6下需要将position设置为absolute
position:fixed;bottom:60px;_position:abosulte;
给浮动元素加一个属性标识,js通过这个属性能找到这些浮动元素。tag="floatNavigator"
工作中浮动导航条主要通过top或者bottom来定位。
//ie6兼容position:fixed
function fixedPositionCompatibility(){
//判断是否ie6浏览器
if( $.browser.msie
|| parseInt($.browser.version,10)
<= 6){
var vavigators = ("[tag=′floatNavigator′]");if(!navigators.length)return;//判断每个浮层是靠顶部固定还是底部固定.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";
});
});
}
}
相关文章推荐
- javascript ie6兼容position:fixed实现思路
- javascript ie6兼容position:fixed实现思路
- javascript实现ie6兼容position:fixed
- 【JavaScript】利用滚动事件window.onscroll与position:fixed写兼容IE6的回到顶部组件
- 【JavaScript】利用滚动事件window.onscroll与position:fixed写兼容IE6的回到顶部组件
- IE6下实现position:fixed
- 让IE6兼容position:fixed
- chrome不兼容position:fixed 对联广告JS 不用JS做对联广告效果 CSS实现对联广告效果
- IE6解决无法实现position:fixed浮动层固定在滚动页面(无抖动)
- 解决IE6不兼容position:fixed
- 实现 IE6 支持 position fixed 的 CSS 属性
- position:fixed;在IE6中的完美实现
- 实现 IE6 下支持 position-fixed 的 CSS 属性并解决“振动”的问题
- IE6下position:fixed;兼容
- ie6不兼容position:fixed的解决方法
- 兼容ie6的position:fixed,但所有的定位将全变成fixed
- 解决position:fixed在IE6下的兼容问题;
- 在ie6下实现position-fixed的效果
- chrome不兼容position:fixed 对联广告JS 不用JS做对联广告效果 CSS实现对联广告效果
- IE6解决无法实现position:fixed浮动层固定在滚动页面(无抖动)