Last active
December 22, 2015 20:29
-
-
Save vctrfrnndz/6526989 to your computer and use it in GitHub Desktop.
Ultimate grid mixin
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
// Group class for clearing floats | |
.group { | |
&:before, | |
&:after { | |
content: " "; | |
display: table; | |
} | |
&:after { | |
clear: both; | |
} | |
*zoom: 1; | |
} | |
// Grid mixin | |
.create-grid(@cols: 1, @padding: 0) { | |
width: auto; | |
margin-right: -@padding; | |
.item { | |
float: left; | |
width: (100% / @cols); | |
padding-right: @padding; | |
} | |
} | |
// Sample usage | |
.grid { | |
.group; | |
&.grid-1 { | |
.create-grid(1); | |
} | |
&.grid-2 { | |
.create-grid(2, 2%); | |
} | |
&.grid-3 { | |
.create-grid(3, 2%); | |
} | |
&.grid-4 { | |
.create-grid(4, 3%); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🚢 Looking good.