I am encountering an issue with the code block below:
<div class="1">
Foo<br>1
</div>
<div class="2">
Bar<br>2
</div>
Even though both .1
and .2
have styles of
position:relative;display:inline-block
, they are displaying as follows:
Bar
Foo 2
1
It appears that the content of class .2
is vertically positioned correctly, but the first line of class .1
starts at the same level as the second line of .2
, causing the entire div to be pushed down. This behavior is unexpected because .2
comes after .1
, leading me to anticipate that .2
should be positioned relative to where .1
is located, not vice versa. This issue persists even when additional divs are added before .1
. Is there a way to align them horizontally like this?
Foo Bar
1 2