Created
August 19, 2013 14:00
-
-
Save webone2up/6269465 to your computer and use it in GitHub Desktop.
Less mixin to create grid system
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
/* 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); | |
} |
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
/* 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