Can you explain why the green item in this line-height and inline-block setup is a few pixels below the middle? Shouldn't there be an equal 15px above and below?
.container{
height: 45px;
line-height: 45px;
background-color: red;
display: inline-block
}
.item{
height: 15px;
width: 15px;
background-color: green;
vertical-align: middle;
display: inline-block
}
<div class="container">
<div class="item">
</div>
</div>
I understand that there are various methods for aligning items vertically, such as using JavaScript, absolute positioning, and more. I am not looking for a general solution to how to vertically align a div.