I have encountered a strange behavior in my design today.lets me show you my code first and then discuss it
*,
*:after,
*::before {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body,
html {
height: 100%;
padding: 0;
}
#all-content,
#content-outer,
#content-inner {
height: 100%;
position: relative;
}
#content-inner {
overflow-y: scroll;
}
.block {
display: inline-block;
font-size: 0;
background-color: yellow;
width: 50px;
height: 50px;
border: 3px solid black;
}
<div id="all-content">
<div id="content-outer">
<div id="content-inner">
<div id="main-field">
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
</div>
</div>
</div>
</div>
The thing is, with this code, there is a strange top padding applied to #main-field
element.
There are two ways fix this.Either with applying a line-height : 50px
rule to the .block
class or change the font-size to something other than zero.
I want to know why is this happening since I've never encountered something strange like this behavior.