Skip to content

Instantly share code, notes, and snippets.

@ezersky
Forked from ChrisTM/block-grid.less
Last active September 16, 2015 19:38
Show Gist options
  • Save ezersky/f8a61135f174d210d65c to your computer and use it in GitHub Desktop.
Save ezersky/f8a61135f174d210d65c to your computer and use it in GitHub Desktop.
[class*="block-grid-"] {
display: block;
margin: -(@grid-gutter-width/2);
padding: 0;
.clearfix();
}
.block-grid-item {
display: inline;
margin: 0;
padding: (@grid-gutter-width/2);
height: auto;
float: left;
width: 100%;
list-style: none;
}
.block-grid (@per-row) {
& > .block-grid-item {
width: (100%/@per-row);
@nth-equation: ~"@{per-row}n+1";
&:nth-of-type(n) { clear: none; }
&:nth-of-type(@{nth-equation}) { clear: both; }
}
}
// Recursive loop that produces rules for block grids of @per-row many items
// per row down to 1 many items per row.
.block-grids(@size, @per-row: @grid-columns) when (@per-row > 0) {
.block-grid-@{size}-@{per-row} { .block-grid(@per-row); }
.block-grids(@size, (@per-row - 1));
}
.block-grids(xs);
@media (min-width: @screen-sm-min) { .block-grids(sm) }
@media (min-width: @screen-md-min) { .block-grids(md) }
@media (min-width: @screen-lg-min) { .block-grids(lg) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment