我想訂購我的div以這樣的方式,但我不能找到一個解決方案(主要有與黃箱有問題):格上述以外的div
HTML:
<div class="container">
<header>
<div id="header-top"></div>
<div id="header-bottom" class="clearfix">
</header>
<div style="clear:both"></div>
<div id="content">
</div>
CSS:
header {padding: 0;margin:0; position: relative; z-index: 1;}
#header-top {
height: 22px;
background-color: #a68572;
margin:0;
padding: 0;
}
#header-top p {text-align: right;}
#header-bottom {
width: 100%;
background-color: red;
padding: 0;
margin: 0;
}
#logo {
position:relative;
height: 150px;
width: 150px;
background-color: yellow;
z-index: 30;
top:-80px;
left: 50px;
}
#content {position: relative;z-index: 1;}
正如你看到的我一直在試着做的立場和Z-的東西但不是很好;)
而且,順便說一句,如何擺脫標題底部和內容之間的空白區域?所有的填充和邊距都設置爲0,所以我不知道它們爲什麼不直接相鄰。
爲什麼你清楚了嗎?你沒有浮動元素。我試圖做一個小提琴 –
好吧,我一直在嘗試不同的解決方案,並且在我添加清除後,標題底部正確顯示。 – Dandy
最好使用[clearfix](http://www.sitepoint.com/clearing-floats-overview-different-clearfix-methods/)進行清除,然後您不需要額外的標記。你還沒有顯示你的徽標在上面的html中的位置 – Pete