I'm trying to use vertical-align: middle
to vertically center an inline-block
element within some text.
p {
background: red;
line-height: 20px;
display: block;
}
span {
height: 18px;
width: 18px;
display: inline-block;
background: lightblue;
vertical-align: middle;
}
<p>
<span></span>
<-- Not perfectly aligned
</p>
Notice that the element isn't perfectly centered... why is this? Is this a browser off-by-one issue? It repros on WebKit browsers (Chrome, Safari).
Stuff
all on one line – Matt Saunders Mar 14 '20 at 14:56