【发布时间】:2012-06-14 01:44:35
【问题描述】:
我有一个位置固定的标题(动态高度)。
我需要将容器 div 放在标题的正下方。由于页眉高度是动态的,我不能使用固定值作为上边距。
如何做到这一点?
这是我的 CSS:
#header-wrap {
position: fixed;
height: auto;
width: 100%;
z-index: 100
}
#container{
/*Need to write css to start this div below the fixed header without mentioning top margin/paading*/
}
...和 HTML:
<div id="header-wrap">
<div id="header">
<div id="menu">
<ul>
<li><a href="#" class="active">test 0</a></li>
<li><a href="#">Give Me <br />test</a></li>
<li><a href="#">My <br />test 2</a></li>
<li><a href="#">test 4</a></li>
</ul>
</div>
<div class="clear">
</div>
</div>
</div><!-- End of header -->
<div id="container">
</div>
【问题讨论】:
-
固定标题不是布局的一部分。它是漂浮的。你需要给内容一个
margin-top,这样它就好像标题在那里一样。