* {
margin: 0;
padding: 0;
}
.container {
position: absolute;
font-size: 12px;
font-weight: 400;
line-height: 0;
}
.child {
display: inline-block;
width: 0;
height: 0;
}
<div class="container">
<div class="child"></div>
</div>
While the code itself is simple, I'm unsure why the .container
element has a height of 4px
.
When I change the display style of .child
to inline
or block
, the height of .container
becomes 0
.