I am looking to display multiple rows of data, with each row potentially having a spacer element that shifts the text on that row to the right. The spacer needs to be contained in its own div element for styling purposes such as adding borders or background colors. Similarly, the text within each row also needs to be in a separate div for individual styling options. It is important to note that the text content within these divs may exceed the boundaries of the containing box.
https://i.sstatic.net/qOXQv.png
I have experimented with CSS properties like float:left
, but I am having difficulty clearing the float to achieve proper row alignment. I have also tried using display:inline-block
, but have not been successful in implementing it effectively.
Below is a snippet of the basic HTML structure I have been working with. Despite trying various CSS configurations, I believe starting from scratch may result in a more optimized solution.
<div class="row">
<div class="text" style="width:500px;">Row one text</div>
</div>
<div class="row">
<div class="spacer" style="width:500px;">Row two spacer</div>
<div class="text" style="width:200px;>Row 2 text</div>
</div>
<div class="row">
<div class="spacer" style="width:700px;">Row three spacer</div>
<div class="text" style="width:100px;">Row 3 text overflowing</div>
</div>