Last active
August 29, 2015 14:07
-
-
Save jackabox/6f5b65b1e52095972e19 to your computer and use it in GitHub Desktop.
Generating a grid in sass.
This file contains hidden or 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
| // Your columns are at a weird width here - Use the gutter on the row as well. | |
| $width: 1244px; | |
| $columns: 12; | |
| $gutter: 16px; | |
| .row { | |
| width: 100%; | |
| max-width: $width; | |
| box-sizing: border-box; | |
| padding: 0 $gutter; | |
| &:after { | |
| content: ""; | |
| display: table; | |
| clear: both; | |
| } | |
| } | |
| .column, | |
| .columns { | |
| float: left; | |
| min-height: 1px; | |
| margin-left: $gutter; | |
| &:first-child{ | |
| margin-left: 0; | |
| } | |
| } | |
| @function columns($i){ | |
| @return ( ($width/$columns) * $i ) / $width * 100; | |
| } | |
| @for $i from 1 through $columns{ | |
| .col-#{$i}.column { | |
| width: calc( #{columns($i)}% - #{$gutter}); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment