2
I want to create a layout in which the first div
uses 100% of the width of a section
and the others divs
use 50%, creating a block.
However, by adding more than 3 divs
they don’t line up like in the first picture
even using the property flex-wrap
.
How do I align 2 elements in each row after the first line you have width 100%?
Html code :
<main>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
<aside>
</aside>
</main>
código css :
main section, main aside {
flex: 1;
border: 1px solid #000;
display: flex;
width: 512px;
flex-direction: row;
box-sizing: border-box;
flex-wrap: wrap;
}
main section {
background : green;
}
main aside {
background : blue;
}
main section div {
border: 1px solid #000;
flex-grow: 1;
}
main section div:nth-child(1) {
background: red;
width: 100%;
}
main section div:nth-child(2) {
background: yellow;
}
main section div:nth-child(3) {
background: purple;
}
main section div:nth-child(4) {
background: brown;
}
main section div:nth-child(5) {
background: gray;
}
thank you very much ! minimized the code and helped a lot.
– Luis
@Luis happy to have helped, flex is very good, continue the studies []s
– hugocsl