Skip to content

Instantly share code, notes, and snippets.

@nelsonJM
Created October 25, 2012 18:05
Show Gist options
  • Select an option

  • Save nelsonJM/3954369 to your computer and use it in GitHub Desktop.

Select an option

Save nelsonJM/3954369 to your computer and use it in GitHub Desktop.
Compass: Grid ala CSS tricks
@import "normalize"; /* import your _normalize.scss file */
@import "compass";
* {
@include box-sizing(border-box);
}
$pad: 20px;
.grid {
background: white;
margin: 0 0 $pad 0;
&:after {
/* Or @extend clearfix */
content: "";
display: table;
clear: both;
}
}
[class*='col-'] {
float: left;
padding-right: $pad;
.grid &:last-of-type {
padding-right: 0;
}
}
.col-2-3 {
width: 66.66%;
}
.col-1-3 {
width: 33.33%;
}
.col-1-2 {
width: 50%;
}
.col-1-4 {
width: 25%;
}
.col-1-8 {
width: 12.5%;
}
/* Opt-in outside padding */
.grid-pad {
padding: $pad 0 $pad $pad;
[class*='col-']:last-of-type {
padding-right: $pad;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment