Created
June 30, 2014 01:51
-
-
Save a-axton/4f15d0490d857fa79ba7 to your computer and use it in GitHub Desktop.
Bootstrap style grid using neat and SASS maps
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
| // replace map keys with whatever you want | |
| // creats classes as .grid-$keyname-$col | |
| $breakpoint-widths: (xs: 480px, sm: 768px, md: 992px, lg: 1200px); | |
| $grid-columns: 12 | |
| // media query mixin | |
| @mixin mq($search) { | |
| @media (min-width: map-get($breakpoint-widths, $search)){ | |
| @content | |
| } | |
| } | |
| @mixin build-grid(){ | |
| @each $name, $width in $breakpoint-widths { | |
| @media (min-width: $width){ | |
| @for $i from 1 through $grid-columns { | |
| // span-columns() is a neat.bourbon.io function to generate grid width | |
| .grid-#{$name}-#{$i} { @include span-columns($i); } | |
| } | |
| } | |
| } | |
| } | |
| // build grid classes | |
| @include build-grid(); | |
| // create media query from map with breakpoint name | |
| @include mq(lg){ | |
| body { | |
| background: purple; | |
| } | |
| } |
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
| <div class="grid-xs-12 grid-sm-8 grid-med-6 grid-lg-4">Hello World</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment