<div style="position:absolute;left:256px;background-color:blue;">
<p>
bla bla bla bla bla bla bla bla bla
</p>
</div>
<div style="position:absolute;top:100px;left:256px;background-color:blue;word-wrap: wrap-word;">
<p>
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
</p>
</div>
<div style="position:absolute;top:200px;text-align: center;background-color:blue;width:100%;word-wrap: wrap-word;">
<p style="width:100%">
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
</p>
</div>
The issue arose when setting the width to 100% and left to 256px, causing the div to take up 100% of the screen width starting from 256px from the left.
To resolve this, simply update left: 256px;
For center alignment, use text-align: center;
<div style="position:absolute;left:256px;background-color:blue;">
<p>
bla bla bla bla bla bla bla bla bla
</p>
</div>
<div style="position:absolute;top:100px;left:256px;background-color:blue;word-wrap: wrap-word;">
<p>
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
</p>
</div>
<div style="position:absolute;top:200px;background-color:blue;left: 256px; width:calc(100%-256px);word-wrap: wrap-word;">
<p style="width:100%">
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
bla 0 bla 1 bla 2 bla 3 bla 4 bla 5 bla 6 bla 7 bla 8 bla 9
</p>
</div>
If you still prefer using left: 256px
, utilize the calc()
function in CSS
This will subtract 256px from the 100% width, providing the div with the width desired
If central text alignment is needed within the below div, add text-align: center
to the <p>
tag.