Created
November 10, 2012 11:37
-
-
Save richardsweeney/4050845 to your computer and use it in GitHub Desktop.
A mixin for creating grid columns on the fly (pixel based: non-responsive)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$columns: 16; | |
$gridWidth: 960px; | |
@mixin drupalCols($rows: 4, $padding: 0 10px) { | |
width: ($gridWidth / $columns) * $rows; | |
float: left; | |
padding: $padding; | |
@include box-sizing(border-box); | |
} | |
.my-div { | |
@include drupalCols(8); | |
} | |
// This becomes: | |
/* | |
.my-div { | |
width: 480px; | |
float: left; | |
padding: 0 10px; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
*/ | |
// You can also add more or less padding like this: | |
.my-div { | |
@include drupalCols(4, 10px 20px 30px); | |
} | |
/* | |
.my-div { | |
width: 240px; | |
float: left; | |
padding: 10px 20px 30px; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment