Skip to content

Instantly share code, notes, and snippets.

@webone2up
Created August 19, 2013 14:00
Show Gist options
  • Save webone2up/6269465 to your computer and use it in GitHub Desktop.
Save webone2up/6269465 to your computer and use it in GitHub Desktop.
Less mixin to create grid system
/* Less mixin to create grid system */
.grid(@grid_context,@grid_margin,@grid_cols){
@grid_n_context: @grid_context + @grid_margin;
.grid_l(@index) when (@index > 0){
@selector: ~".grid_@{index}";
@margin: @grid_margin/@grid_context;
@grid_col_size: @grid_n_context/@grid_cols;
@{selector}{
width: percentage(((@index*@grid_col_size)/@grid_context) - @margin);
margin-right: percentage(@margin);
float: left;
};
.grid_l((@index - 1));
}
.grid_l(0){}
.grid_l(@grid_cols);
}
/* How to use /*
/* Call the function with parameters */
.grid(@grid_context,@grid_margin,@grid_cols);
* > div[class^="grid-"]:last-child,
div[class*="grid-"]:last-child{
margin-right: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment