2
How can I align the div’s so that the white part is filled with the elements below it (5,6,7)?
main {
width: 200px;
display: flex;
flex-wrap: wrap;
text-align: center;
line-height: 50px;
font-size: 15px;
font-weight: bold;
color: #fff;
}
div {
width: 50px;
height: 50px;
background-color: #581b98;
}
div:first-child {
height: 100px;
background-color: #ff304f;
}
div:last-child{
background-color: #faee1c;
}
/*Flecha para exemplo*/
#teste{
position: absolute;
transform: rotate(300deg) translate(100px, 30px);
clip-path: polygon(0% 20%, 60% 20%, 60% 0%, 100% 50%, 60% 100%, 60% 80%, 0% 80%);
background: red;
}
<main>
<div></div>
<div></div>
<div></div>
<div></div>
<div>5</div>
<div>6</div>
<div>7</div>
<div></div>
</main>
<div id="teste"></div>
Maybe if you use display grid and
dense
, you get the result you want– hugocsl
What you’re trying to do is call masonry layout, to achieve the result you only expect with CSS using flexbox, you’d have to change the flow of Row to column, without varying the width of the items ... or as @hugocsl said, use the grid technique. Here’s the link to a great article to better understand how it works https://w3bits.com/css-masonry/
– Vinicius Colares
Use Grid Area. See this Video from 02:05:18 If I explained maybe you wouldn’t understand, but in the video you will understand the logic
– Cauã