我有一個固定位置的標題(動態高度)。在html中的位置固定標題
我需要將容器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',這樣它的行爲就好像標題在那裏一樣。 – Blender
閱讀本文http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/ – sandeep
[CSS-Only Scrollable Table with fixed headers]可能出現重複(http:// stackoverflow。 com/questions/11891065/css-only-scrollable-table-with-fixed-headers) –