I’m try to compile this .less code to .css via lessphp and get this error:
Fatal Error:
====================
infinite loop detected: @pos-x: failed at `background-position: @pos-x 0; }` line: 3
Here is my code.
@pos-x : 0;
@w : 30px;
.a { background-position: @pos-x 0; }
@pos-x: @pos-x - @w;
.b { background-position: @pos-x 0; }
What’s wrong with it? Can i use varable overriding in LESS?
@pos-x: @pos-x - @w;is not allowed. The documentation states, “Note that variables in LESS are actually ‘constants’ in that they can only be defined once.”I believe what happens with LESS in such a case is essentially this:
Thus, it continually recalculates the
@pos-xtrying to come to a final resolution which is never reached. Everytime it is reassigned, it attempts to reevaluate based off that new assignment.So do something like this: