Can you explain why the code below doesn't display correctly in Firefox unless the parent span
is set to display as inline-block
? When inspecting the layout of the absolutely positioned span, it shows the number 184 instead of 197 on the right side. Adding display:inline-block
to the parent span resolves the issue.
<span style="position:relative; font-size:52px;">FOO BAR
<span style="position:absolute; top:-17px; right:197px; height:22px; width:22px; background-color:black"></span>
</span>
<span style="position:relative; font-size:52px; display:inline-block">FOO BAR
<span style="position:absolute; top:-17px; right:197px; height:22px; width:22px; background-color:black"></span>
</span>
Other browsers have no problem with this rendering.