我很早就注意到,当两个块元素彼此相邻时,它们的边缘相互叠加.像这样的东西:
两个< div>都有保证金:1em,但当margin1的margin-bottom与margin2的margin-top碰撞时,两个保证金都相互叠加.见这里:http://jsfiddle.net/39XmC/
我所期待的是这样的:
两个< div> s实际上在每个边距上给出空格并且不在彼此的边缘上堆叠.
我知道这可以通过floating修复或溢出元素.我的问题:
最佳答案
这种行为是正常的,它被称为崩溃边缘..
引自W3C:
In CSS,the adjoining margins of two or more Boxes (which might or
might not be siblings) can combine to form a single margin. Margins
that combine this way are said to collapse,and the resulting combined
margin is called a collapsed margin.Adjoining vertical margins collapse,except:
原文地址:https://www.jb51.cc/css/427361.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。