I have the following bit of LESS code working
@iterations: 940;
@iterations: 940;
@col:2.0833333333333333333333333333333%;
I don't think you're far off. What I've done is create a second variable inside the mixin, called @index2
. All this does is find the '920px minus @index' value that you're looking for:
@index2 = (920-@index);
this is then appended to the class name:
(~".gs@{index}-@{index2}") {
This is the complete loop:
.loopingClass (@index) when (@index > 160) {
@index2 = (920-@index);
// create the actual css selector, example will result in
// .myclass_30, .myclass_28, .... , .myclass_1
(~".gs@{index}-@{index2}") {
// your resulting css
width: (@index/20+1)*@col;
}
// next iteration
.loopingClass(@index - 60);
}
// "call" the loopingClass the first time with highest value
.loopingClass (@iterations);
In order to get just the set you are looking for (gs220-700 to gs700-220), just change @iterations
to equal 700.
Worth noting that currently, this will create the classes in the reverse order of how you specified them in the question.