Skip to content

Instantly share code, notes, and snippets.

@lumpysimon
Created June 18, 2014 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lumpysimon/97dcedd7a1ba484a588d to your computer and use it in GitHub Desktop.
Save lumpysimon/97dcedd7a1ba484a588d to your computer and use it in GitHub Desktop.
SASS/SCSS responsive columns
/*
===========
= columns =
===========
*/
$gutter: 4%;
.cols {
@extend %clearfix;
}
.col {
margin-bottom: $gap;
}
@include breakpoint( $break-3 ) {
.col {
float: left;
margin-right: $gutter;
@extend %clearfix;
&:last-of-type {
margin-right: 0;
}
& .col {
margin-bottom: 0;
}
}
.col-1-2 {
width: ( 100 - $gutter ) / 2;
}
.col-1-3 {
width: ( 100 - 2 * $gutter ) / 3;
}
.col-2-3 {
width: ( ( ( 100 - 2 * $gutter ) * 2 ) / 3 ) + $gutter;
}
.col-1-4 {
width: ( 100 - 3 * $gutter ) / 4;
}
.col-2-4 {
width: ( ( ( 100 - 3 * $gutter ) * 2 ) / 4 ) + $gutter;
}
.col-3-4 {
width: ( ( ( 100 - 3 * $gutter ) * 3 ) / 4 ) + 2 * $gutter;
}
.col-1-5 {
width: ( 100 - 4 * $gutter ) / 5;
}
.col-2-5 {
width: ( ( ( 100 - 4 * $gutter ) * 2 ) / 5 ) + $gutter;
}
.col-3-5 {
width: ( ( ( 100 - 4 * $gutter ) * 3 ) / 5 ) + 2 * $gutter;
}
.col-4-5 {
width: ( ( ( 100 - 4 * $gutter ) * 4 ) / 5 ) + 3 * $gutter;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment