Answer the question
In order to leave comments, you need to log in
Variable scope in LESS?
Tell me, please, I'm trying to set a value for the variable @pageWidth = @viewPortType, that is, @pageWidth: @viewPortType, depending on the width of the viewport window, that is, through mediaqueries. So for
@media only screen and (min-width: 1170px) {
@viewPortType: 1170px;
}
@media only screen and (max-width: 1170px) {
@viewPortType: 940px;
}
Answer the question
In order to leave comments, you need to log in
lesscss.org/features/#features-overview-feature-scope
You are including a file where the @viewPortType variable is defined twice, each time in a different scope. And how can LESS decide which value to use in the main file? No way. Do this:
@viewPortTypeDesktop: 1170px;
@viewPortTypeTablet: 940px;
@media only screen and (min-width: 1170px) {
@viewPortType: @viewPortTypeDesktop;
}
@media only screen and (max-width: 1170px) {
@viewPortType: @viewPortTypeTablet;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question