I have a very simple setup:
<button>
Lorem
</button>
<input type="text" value="Ipsum">
with both elements next to each other using display: inline-block
:
button, input{
height: 34px;
line-height: 34px;
display: inline-block;
box-sizing: border-box;
vertical-align: baseline;
padding: 0;
margin: 0;
border: 1px solid green;
font-size: 14px;
}
Example here: http://jsfiddle.net/j02ypo0v/
As you can see, the two elements are not perfectly aligned (off 1px).
I know, I could easily solve this by changing vertical-align
to middle
, but I want to understand why this offset is present in the first place.
IMO, it doesn't make any sense that the two elements are not perfectly vertically aligned since they share all CSS attributes (especially height
, line-height
, display
and vertical-align
).
Can anybody explain me where the 1px offset is coming from?