为什么我不能保证 div,为什么我必须保证 child 才能保证 div?
Why can't I margin the div, why do I have to margin the child to margin the div?
这有 2 个修复...这对我来说真的很奇怪。
1:如果我删除标签 #MARGIN-30 并删除标签 #Nav-bar 在 margin-3 下,当我重新应用所述标签时它会自行修复。
2:如果我加上overflow:hidden;
问题是,是否有人能够帮助我了解发生这种情况的原因,例如...我在之前的任何项目或学习经验中都没有遇到过这种情况 css。
看来您正成为 Margin Collapse 的受害者。这只是 HTML/CSS.
中许多有点奇怪的事情之一
The top and bottom margins of blocks are sometimes combined (collapsed) into a single margin whose size is the largest of the individual margins (or just one of them, if they are equal), a behavior known as margin collapsing. Note that the margins of floating and absolutely positioned elements never collapse.
这有 2 个修复...这对我来说真的很奇怪。
1:如果我删除标签 #MARGIN-30 并删除标签 #Nav-bar 在 margin-3 下,当我重新应用所述标签时它会自行修复。
2:如果我加上overflow:hidden;
问题是,是否有人能够帮助我了解发生这种情况的原因,例如...我在之前的任何项目或学习经验中都没有遇到过这种情况 css。
看来您正成为 Margin Collapse 的受害者。这只是 HTML/CSS.
中许多有点奇怪的事情之一The top and bottom margins of blocks are sometimes combined (collapsed) into a single margin whose size is the largest of the individual margins (or just one of them, if they are equal), a behavior known as margin collapsing. Note that the margins of floating and absolutely positioned elements never collapse.