I am trying to create following structure:
.rowblock {
display: flex;
padding: 0.5rem;
width: 100%;
flex-direction: row;
}
.col {
height: 50px;
border: 1px solid #ccc;
}
<div class="rowblock">
<div class="col">10% Width</div>
<div class="col">80% Width</div>
<div class="col">100% on Next Row</div>
<div class="col">10%</div>
</div>
I am trying to move the 3rd column to next row to occupy full width and tried with flex grow but did not worked, pls suggest approach.
2
Answers
Try this:
In the modified code, I added the flex-wrap: wrap; property to the .rowblock class to allow the columns to wrap onto the next line when necessary.
For the columns, I used the flex-basis property to specify the initial width as a percentage. The first column has a width of 10%, the second column has 80%, the third column has 100% (which forces it onto the next row), and the fourth column has 10%.
With these modifications, you should achieve the desired structure with the specified column widths.
UPDATED:
I’ve updated the code with the
order
property as well as subtracting 2px in theflex-basis
property to make up for the px’s added by the col border.