Skip to content

Instantly share code, notes, and snippets.

@daphotron
Created June 17, 2016 18:12
Show Gist options
  • Save daphotron/9cb2d3c21c5e684491acc2420dbc119d to your computer and use it in GitHub Desktop.
Save daphotron/9cb2d3c21c5e684491acc2420dbc119d to your computer and use it in GitHub Desktop.
Making multiple columns out of an unordered list
// FLEXIBLE 3 COL ====================
$em-base: 16px;
$bp-widest: 900px/$em-base + 0em;
$bp-wide: 700px/$em-base + 0em;
.span3 {
display: block;
@media (min-width: $bp-wide) {
// 2 col
float: left;
margin-right: 2%;
width: 48%;
}
@media (min-width: $bp-widest) {
// 3 col
width: 32%;
}
}
// first of 2
.span3:nth-child(2n+1) {
@media (min-width: $bp-wide) and (max-width: $bp-widest) {
clear: left;
}
}
// last of 2
.span3:nth-child(2n) {
@media (min-width: $bp-wide) and (max-width: $bp-widest) {
margin-right: 0;
}
}
// first of 3
.span3:nth-child(3n+1) {
@media (min-width: $bp-widest) {
clear: left;
}
}
// last of 3
.span3:nth-child(3n) {
@media (min-width: $bp-widest) {
margin-right: 0;
}
}
// FLEXIBLE 2 COL ====================
.span2 {
display: block;
@media (min-width: $bp-wide) {
// 2 col
float: left;
margin-right: 2%;
width: 48%;
}
}
// first of 2
.span2:nth-child(2n+1) {
@media (min-width: $bp-wide) {
clear: left;
}
}
// last of 2
.span2:nth-child(2n) {
@media (min-width: $bp-wide) {
margin-right: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment