我有以下的HTML/CSS代碼:元素忽略容器元素的填充
<div id="container" style="padding:5px; width:600px;">
<div id="panel">
<a style="padding:5px; color:#ffffff; background-color:#000000;">Page 1</a>
<!-- Other anchor elements -->
</div>
<!-- Other panels -->
</div>
我很難理解爲什麼#panel
元素坐在舒適的#container
內;服從它的填充規則,而填充#panel
中的錨元素的填充與#container
重疊。任何人都會介意解釋爲什麼會出現這種情況,並且這樣做或許會提出一個解決方案?
謝謝,這是行得通的,但是你知道爲什麼內聯元素的行爲與我在OP中描述的一樣嗎? – TheBoss
@TheBoss看到[this](http://stackoverflow.com/questions/1401140/padding-the-top-and-the-bottom-of-inline-element)問題 – Musa
謝謝。我確實希望這種行爲有一個很好的理由,或者如果有的話,解釋原因的資源。 – TheBoss