I am looking to do a for loop inside of Less. Is it possible to do this inside of Less? I know it has the capability to evaluate js but to this degree?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I will recommend to checkout Twitter Bootsrap. They are building their grid system that way. They loop, with recursion, in a less mixin, instead of typing every class they need.
The interesting part is in mixins.less file, in the less directory, below “// The Grid” comment (line 516). The interesting portion is:
Which is called in grid.less file in less directory this way:
Which produce (among other things):
in bootstrap.css line 170.
For @gridColumnWidth, @gridGutterWidth and the rest of variables check variables.less file (line 184)
Be sure to have the last version of lessc node compiler installed.