Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CSS Flexbox with specified number of boxes in rows
.flex-container {
display: flex;
flex-wrap: wrap;
--flex-gap: 1.25rem;
gap: var(--flex-gap);
}
.flex-child {
--flex-items-per-row: 3;
width: calc(
calc(100% - calc(var(--flex-items-per-row) * var(--flex-gap))) /
var(--flex-items-per-row)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment