我是新來的HTML/CSS,我剛開始圍繞定位打包,但我似乎有一個誤解。現在我試圖在它下面創建一個水平分隔符的頁眉。我的標題絕對定位,頂部和左側值爲0,高度爲88.我認爲如果我給出了水平分隔符的位置:relative,高度爲5,那麼它會直接位於標題的下方。相反,它會在頁面的最頂部結束,我爲什麼會感到困惑。相對和絕對定位混淆
我想再次在我的頁面上使用這個水平分隔符,在我的頁腳上方,所以我不想給這個水平分隔符position: absolute
和top: 88px
。任何幫助表示讚賞,非常感謝!
我的(非常簡單的)碼到目前爲止:
<div id="header"></div>
<div class="horizontal-divider"></div>
#header {
position: absolute;
top: 0px;
left: 0px;
height: 88px;
width: 100%;
}
.horizontal-divider {
position: relative;
height: 5px;
width: 100%;
top: 0px;
background-color: white;
border: 1px solid black;
}
W3Schools的[有很多問題](http://www.w3fools.com/),最好避免。 – Quentin