fixed定位(ie6下模拟fixed定位) 和标准布局的切换
来源:互联网 发布:js使input不可编辑 编辑:程序博客网 时间:2024/05/21 08:41
fixed定位(ie6下模拟fixed定位) 和标准布局的切换,历经一天才发现ie6这个问题,废话不说直接看代码
第一步: 防止抖动:
var isIE6 = !!window.ActiveXObject && !window.XMLHttpRequest;
if (isIE6&&document.body.currentStyle.backgroundAttachment!== 'fixed'){
html=document.getElementsByTagName('html')[0],
html.style.backgroundImage = 'url(about:blank)';
html.style.backgroundAttachment = 'fixed';
}
第二步 ie6下使用expression定义top,或者left例如
h3.fixed{position:fixed; top:0px;_position:absolute;_top:expression(documentElement.scrollTop);}
注意ie6下此元素不能再定定义其他class 例如<h3 class="ul_wrap"></h3>这样的写的话expression就不起作用了啊
第三步 绑定事件,加上你的逻辑。
具体我的测试代码在这里;有疑问的可以联系我 qq:38926469
第一步: 防止抖动:
var isIE6 = !!window.ActiveXObject && !window.XMLHttpRequest;
if (isIE6&&document.body.currentStyle.backgroundAttachment!== 'fixed'){
html=document.getElementsByTagName('html')[0],
html.style.backgroundImage = 'url(about:blank)';
html.style.backgroundAttachment = 'fixed';
}
第二步 ie6下使用expression定义top,或者left例如
h3.fixed{position:fixed; top:0px;_position:absolute;_top:expression(documentElement.scrollTop);}
注意ie6下此元素不能再定定义其他class 例如<h3 class="ul_wrap"></h3>这样的写的话expression就不起作用了啊
第三步 绑定事件,加上你的逻辑。
具体我的测试代码在这里;有疑问的可以联系我 qq:38926469
$(window).scroll(function(){var sc_top=$(this).scrollTop();//获取滚动条的距离;var top=$("h3").offset().top;if((sc_top>top)&&(sc_top<(top+$("h3").outerHeight(true)))){$("h3").addClass("fixed");}else{$("h3").removeClass().removeAttr("style");//ie6必须删除style,应为ie6下 expression就是相当于在该元素加了一个style;}});
$(window).scroll(function(){var sc_top=$(this).scrollTop();//获取滚动条的距离;var top=$("h3").offset().top;if((sc_top>top)&&(sc_top<(top+$("h3").outerHeight(true)))){$("h3").addClass("fixed");}else{$("h3").removeClass().removeAttr("style");//ie6必须删除style,应为ie6下 expression就是相当于在该元素加了一个style;}});
0 0
- fixed定位(ie6下模拟fixed定位) 和标准布局的切换
- fixed 定位在 IE6 下的实现
- ie6 下fixed 定位 --js
- 在IE6下实现fixed定位效果
- fixed 定位在 IE6 下的实现技巧一则
- 解决IE6 下 position:fixed 绝对定位的问题
- expression解决IE6下固定定位(fixed)的兼容问题
- 再谈IE6之Fixed定位
- 再谈IE6之Fixed定位
- 解决IE6浏览器下position:fixed固定定位问题
- 解决IE6浏览器下position:fixed固定定位问题
- 解决IE6浏览器下position:fixed固定定位问题
- 解决IE6浏览器下position:fixed固定定位问题
- 解决IE6浏览器下position:fixed固定定位问题
- fixed定位,解决IE6下有闪动问题
- 解决IE6浏览器下position:fixed固定定位问题
- 解决IE6浏览器下position:fixed固定定位问题
- ie6下的fixed
- Spring的xml配置(extends MultiActiveController)
- STL ATL WTL MFC, COM OLE ActiveX区别与联系
- [转]解密铁路12306手机客户端的开发技术
- hive 结合执行计划 分析 limit 执行原理
- 美国是一个"愚蠢而落后的国度"--大家千万别去
- fixed定位(ie6下模拟fixed定位) 和标准布局的切换
- 循环滑动视图uisctrollview滑动图片
- Java操作MongoDB
- Android - ListActivity 短、长单击事件的响应
- redhat yum源配置方法
- java一些好用的函数自制API
- JQuery遍历取element after the specified element
- 第十六周上机实践项目——打入“内部”寻“内幕”
- lvm使用总结