Skip to content

Instantly share code, notes, and snippets.

@james-jlo-long
Created March 12, 2014 12:48
Show Gist options
  • Save james-jlo-long/9506269 to your computer and use it in GitHub Desktop.
Save james-jlo-long/9506269 to your computer and use it in GitHub Desktop.
Liquid grid in LESS
* {
&,
&:after,
&:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
}
[class*="grid_"] {
float: left;
}
.grid:after {
clear: both;
content: "";
display: table;
}
#grid {
.size(@units, @columns) {
@selector: ~".grid_@{units}of@{columns}";
@{selector} { width: unit(@units * (100 / @columns), ~"%"); }
}
.loop(@index, @columns) when (@index > 0) {
#grid > .size(@index, @columns);
#grid > .loop(@index - 1, @columns);
}
.make(@columns) {
#grid > .loop(@columns - 1, @columns);
}
}
#grid > .make(2);
#grid > .make(3);
#grid > .make(4);
#grid > .make(5);
#grid > .make(6);
#grid > .make(8);
#grid > .make(12);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment