I'm making responsive gallery and would like to avoid using media queries while it can be done with flexbox. I set flex-grow to 1, so the columns fill available space and added min/max-width, so they stay in a nice size. The problem is - when columns start to wrap I have:
- 3 regular columns on first line.
- 2 bigger columns on the second line.
I would like the second line columns to have the same width as the first one.
jsfiddle demo: https://jsfiddle.net/xu92m43e/1/
html:
<div class="gallery">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
scss:
.gallery {
display: flex;
flex-wrap: wrap;
border: solid 5px black;
> * {
flex-grow: 1;
background: purple;
min-width: 175px;
max-width: 300px;
margin: 5px;
&:after {
display: block;
content: '';
padding-bottom: 75%;
}
}
}
Solutions without flexbox may be good too, as long as it can wrap the columns.