Your problem is that you are making the inner span
s absolute relative to the outer span. Since the outer span only has two words in it, it is only that wide.
<span style="position:relative;width: 100%;display: block;">same position
<span style="position:absolute; top:100%; left:0;">same position</span>
<span style="position:absolute; top:100%; right:0;">same position</span>
</span>
This is the code that you want. You will now have the outer span have a width of 100% and the two inner spans will be relative to a wider span and now that you have that you can have the right span at top:100%
, unless you want it further down. However, once you make a span have display:block
, you might as well just make it a div and not have width: 100%;display: block;
You can do display: inline-block
as well if you want it to only be as wide as the parent div.
EDIT Addendum: the inner spans will not look like they are in the outer span because they are position: absolute
, which means that their positioning is absolute and none of their parents will reshape because of them. Since their parent is position: relative
, their absolute positioning is relative to their parent, but they will not actually be inside their parent when it comes to making the parent div larger. Another possible solution that will have the parent include the text within the element is:
<div>
same position
<div style="">same position</div>
<div style="float: right;">same position</div>
</div>