【发布时间】:2023-03-26 05:35:01
【问题描述】:
我的边距之间有这个奇怪的空间,即使对所有元素都使用 0 的边距和填充。谁能帮我理解 Chrome 中的这种行为?
谢谢!
https://jsfiddle.net/rzby6mj7/3/
HTML:
<div class="parent">
<div class="child child-1">ONE</div>
<div class="child child-2">TWO</div>
</div>
CSS:
*{
margin: 0;
padding: 0;
}
.parent{
background-color: pink;
height: 200px;
}
.child{
font-size: 30px;
width: 40%;
display: inline-block;
}
.child-1{
background-color: grey;
}
.child-2{
background-color: yellow;
}
【问题讨论】:
-
添加浮动:左;在 .child 类上。