Skip to content

Instantly share code, notes, and snippets.

@Uvacoder
Created December 16, 2021 13:10
Show Gist options
  • Select an option

  • Save Uvacoder/6c4e9ca13f31e930b2ddbe6653d621d1 to your computer and use it in GitHub Desktop.

Select an option

Save Uvacoder/6c4e9ca13f31e930b2ddbe6653d621d1 to your computer and use it in GitHub Desktop.
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