我有以下结构和布局:
问题:
为什么 margin-top: 6%
计算为 div#content
的像素多于 div#header
的像素?
注意:两个元素的父元素都设置了height: 100%
,就像div#top-container
一样。
我有一种强烈的感觉,这与 div#header
和 div#content
是 float 的事实有关,但我真的可以'弄清楚为什么它会这样。
最佳答案
来自 http://www.w3.org/TR/CSS2/box.html#margin-properties
The percentage is calculated with respect to the width of the generated box's containing block. Note that this is true for 'margin-top' and 'margin-bottom' as well.
关于css - 100%的奇怪计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9173901/