HTML:爲什麼下面的元素顯示在div的底部邊緣?
<div id="header">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150">
<a href="1.html">blah</a>
<a href="2.html">blah</a>
<a href="3.html">blah</a>
</div>
的圖像是一個標誌的佔位符。
CSS:
body {
margin: 0;
padding: 0;
font-family: "Century Gothic", Tahoma, Arial;
}
#header img {
margin-right: 130px;
}
#header a {
text-decoration: none;
margin-right: 60px;
color: #000000;
}
從本質上講,我希望標籤的「嗒嗒」是在圖像的垂直中心。我已經嘗試在「#header a」選擇器中添加底部和頂部填充和邊距,但它不起作用。標籤繼續與圖片的底部邊緣對齊。
你想讓'a'標籤位於中心的圖像上嗎? –
嘗試添加一個行高:## px;到一個標籤。 –
從您的問題中很難分辨出來,但也許您正在尋找verical-align屬性?嘗試在'img'設置'vertical-align:middle'' – peterjb