Why does IE7 not display the same as other browsers with this code?
I have tested it on Chrome, Firefox, and others, and it works fine. But why does IE7 not display the same as other browsers? What can I do about it?
<script>
window.onload=function(){
var element = document.getElementById('element1');
document.getElementById("element2").style.paddingTop = element.offsetHeight + 'px';
}
</script>
<div id="element1" style="position: fixed; height: 50px; background-color: #000; width: 100%;"></div>
<div id="element2" style="position: relative; width: 100%;">
<div id="element3" style="position: relative; height: 50px; background-color: red; width: 100%;">
</div>
</div>
Displayed on IE7
and on other browsers