0
的事情,我想实现是相当简单的职位:固定导致margin-top消失?
- 只是在顶部,而滚动 下来的文件不移动的固定位置元素。
- 和之后是一个div#含量具有从顶缘 和中心在窗口一些边距。
因此代码: HTML
<div class='head-container' id="headerCom">
<header id="a"></header>
</div>
<div id="content" role="main"></div>
CSS
* {
margin: 0;
padding: 0
}
body {
width: 100%;
height: 100%;
position: relative;
}
.head-container {
position: fixed;
top:0;
left:0;
width: 100%;
height: 100px;
background: red;
_position:absolute; // make the ie6 support the fixed position
_top: expression(eval(document.documentElement.scrollTop)); // make the ie6 support the fixed position
}
header {
display: block;
width: 960px;
height: 100px;
margin: 0 auto;
position: relative;
zoom: 1;
background: blue;
}
#content {
border: 1px solid black;
margin: 130px auto 0 auto;
width: 960px;
height: 1000px;
background: #999;
margin-top: 150px;
}
所有现代浏览器很好的支持,但在IE(IE7,IE8,IE10)无法正常工作,事情就像忽略了我设置为div#内容的margin-top;
到目前为止,我已经签计算器上的其他问题,我尝试几乎寄托都我能。
当我改变DIV#内容填充顶的上边距,东西还行。
当我在div.header-container和div#conetent之间放置一个div.clear(clear:both)时,事情就会好起来;
- 或者我按照它造成hasLayout的其他问题的解决方案,然后取出在div#内容的宽度和高度,这个事情也还行,但这样一来,我就需要在div#内容中放置另一个div#inner-content,并设置宽度和高度以查看结果。
,所以我用的hasLayout相当混乱,我不能肯定我完全明白它是什么,不太清楚这里发生了什么,在我的代码。
因此,实际上都可以,你帮我这个,还有没有其他的解决办法可以解决这个问题,并解释这个有线的东西给我吗?
谢谢你的好意。
哦,谢谢你指出这一点!实际上我知道它,这是为了测试,我忘了把它粘贴在这里,**和只是一秒钟,我发现,如果我把DIV.header容器放在DIV#内容下,它将正常工作** ... – Lien 2013-04-20 08:10:25