I have a div set to flex and row wrap. Inside I have a collection of divs each containing a picture. As the width of the viewport increases, they re-arrange themselves correctly, but I would like to limit the number of pictures per row. I can get this done by changing the width of the pictures but that gets tiresome. Is there a simpler way, something like a "max-boxes-per-row" concept? Below is the relevant CSS
#gallery-box {
position: relative;
display: flex;
flex-flow: row wrap;
justify-content: center;
}
.box {
display: inline-block;
width: 80vw;
aspect-ratio: 1/1;
text-align: center;
font-size: 22px;
padding-top: 16px;
font-family: "Quicksand", sans-serif;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
2
Answers
You may want to use
display:grid
so you can specify how manyspan
in 1 row. You can learn more about this grid-column