Reputation: 35
I would like to align the text in the second div to be on the far right side of the first div. Something normally done with text-align: right; however it seems that absolute positioning (which im using so the text doesn't move other elements on the page around) doesn't allow this to work. The two div elements simply phase into one another on the left side of the page.
<div style=" color:#ffffff; position: absolute;">
Im on the left.
</div>
<div style=" color:#ffffff; position: absolute; text-align: right;">
I need to be on the right.
</div>
Upvotes: 0
Views: 1961
Reputation: 193
<div style=" color:#ffffff; position: absolute;top:0;left:20px;">
Im on the left.
</div>
<div style=" color:#ffffff; position: absolute; top:0;right: 20px;">
I need to be on the right.
</div>
Try this, I hope this works fine, And make sure the parent element is having position: relative
if parent is not body
Upvotes: 1