Skip to content

Instantly share code, notes, and snippets.

@NickDeckerDevs
Created March 1, 2022 15:38
Show Gist options
  • Save NickDeckerDevs/133c354bf2a410973abf4644ef046516 to your computer and use it in GitHub Desktop.
Save NickDeckerDevs/133c354bf2a410973abf4644ef046516 to your computer and use it in GitHub Desktop.
I think this is a better way of centering columns when using flexbox and borders between them. nth child the 1st item and the last item with no padding. This also repeats down the line if more than 3 columns are used
.multi-column {
.multi-column__col {
flex-basis: 33%;
margin: 0;
padding-left: 20px;
padding-right: 20px;
&:nth-child(3n+1) {
padding-left: 0;
}
&:nth-child(3n+3) {
padding-right: 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment