我創建這個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