Caveat, I'm very unfamiliar with CSS. I'm probably misusing vertical-align
. I made this very simple example of a problem which I ran into. In the following snippetsI apply vertical-align
to Block 1, however it is block 2 which gets centered. (Snippet two has vertical-align
removed to see the effect.)
Why exactly is happening?
<div style="background-color: gray; height:200px;">
<div style="display: inline-block; background:green; height:200px; vertical-align:middle">Block 1</div>
<div style="display: inline-block; background:red">Block 2</div>
</div>
<div style="background-color: gray; height:200px;">
<div style="display: inline-block; background:green; height:200px;">Block 1</div>
<div style="display: inline-block; background:red">Block 2</div>
</div>