My goal is to display 4-8 boxes in a grid of 2-4 rows.
.twit-container {
display: flex;
flex-wrap: wrap;
padding: 5%;
margin:-10px 0 0 -10px;
position: relative;
}
.twit {
max-width: 200px;
display: inline-block;
padding: 20px;
width: 150px;
min-height: 100px;
margin: 10px 0 0 1%;
background-color: #fff;
border: 1px solid #ccc;
flex-grow: 1;
outline: 2px solid blue;
}
Here's the same thing in grid:
The boxes should expand to fill the available space without being very strictly controlled in size. However whenever I try it if the screenspace isn't sufficient for an even number of items the last row's items deforms.
The idea is to achieve what youtube has:
If there is only enough room for 3 columns, I would like the last row to not be shown at all. In the flexbox example the items blow up in an ugly way, and in the grid they just dangle there.
Is this possible with just flexbox/or grids or other methods without media queries or do I have to calculate based on screen size?