我创建这个code.Everything轻微的未成年人视差效果正常工作无处不在,除了IE.I正在使用IE 9简单的JavaScript不适用于任何IE?
<div id="head"> i </div>
<div id="subHead"> can </div>
<div id="content"> haz </div>
的Javascript
window.onscroll = function(ev){
var subHead = document.getElementById('subHead'),
topHeight = document.getElementById('head').offsetHeight;
subHead.style.top = (topHeight - document.body.scrollTop/4) + 'px';
};
CSS
#head, #subHead{
position: fixed;
height: 80px;
width: 100%;
display: block;
background: #c00;
left: 0;
top: 0;
z-index: 10;
}
#subHead{
z-index: 4;
background: #cd0;
top: 80px;
}
#content{
position: relative;
z-index: 6;
height: 1000px;
background: #eee;
margin-top: 160px;
}
我试着用谷歌搜索一些跨浏览器技巧,但徒劳...有什么办法让它在IE中工作?非常感谢。
编辑:
目的:使1格比另一个当用户滚动移动速度较慢。
逻辑:使通过CSS固定的股利,并通过JavaScript http://jsfiddle.net/MRbWY/11/
错误IE.The改变其现在的位置是JavaScript的犯规work.hence股利仅保留固定
您在IE的开发者控制台中遇到什么错误? – 2013-03-05 06:43:11
什么不工作?在IE中, – 2013-03-05 06:43:16
,“can”这个词是固定的......它不应该是javascript的代码。 – Michel 2013-03-05 06:45:25