Seeking a method to incorporate divs into a container with the ability to specify the left starting position in pixels for each one, while also ensuring that each div automatically stretches to its neighbor sibling's left. I have an array of start positions for each div and could potentially calculate the width for each div in JavaScript. However, I am hoping for a more refined solution.
I have extensively searched for a resolution and thus far, the most viable option I have come across is the flex solution which involves computing the widths:
.s-container {
height: 20px;
background-color: red;
min-width: 100%;
display: flex;
}
.s-child {
border-left: 1px solid black;
background-color: yellow;
height: 100%;
}
<div class="s-container">
<div style="flex-basis:50px;" class="s-child">left: 0</div>
<div style="flex-basis:100px;" class="s-child">left: 50px</div>
<div style="flex-grow:1;" class="s-child">left: 150px</div>
</div>
Is there a way to assign the left position for each div and ensure that each one fills its own width up to the neighboring element on the right?