css边距重叠的实例介绍

这篇文章主要讲解了“css边距重叠的实例介绍”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“css边距重叠的实例介绍”吧!

1、边界重叠是指两个或两个以上盒子的相邻边界重合在一起,构成单一边界。

可以相邻也可以嵌套,其中没有非空内容、补白、边框。

       .neighbor{
height: 100px;
background: red;
}
.father{
background: #f436365e;
}
.child{
height: 100px;
margin-top: 10px;
background: #00800047;
}
<div>
this is neighbor
</div>
<div>
<div>
this is child
</div>
</div>

2、这两个或两个以上块级盒的垂直邻接边界重合,其边界宽度为相邻边界宽度的最大值。

请注意,水平线不重合。

<style type="text/css">
.father{
background: #f436365e;
overflow: hidden;
}
.child{
height: 20px;
margin: 30px auto 30px;
background: #00800047;
}
</style>
<div>
<div>
this is child1
</div>
<div>
this is child2
</div>
<div>
this is child1
</div>
</div>

感谢各位的阅读,以上就是“css边距重叠的实例介绍”的内容了,经过本文的学习后,相信大家对css边距重叠的实例介绍这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!