Skip to content

Instantly share code, notes, and snippets.

@vctrfrnndz
Last active December 22, 2015 20:29
Show Gist options
  • Save vctrfrnndz/6526989 to your computer and use it in GitHub Desktop.
Save vctrfrnndz/6526989 to your computer and use it in GitHub Desktop.
Ultimate grid mixin
// 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%);
}
}
@saibayadon
Copy link

🚢 Looking good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment