I believe eliminating the need for calc
is possible by using the following code:
1
@screen-lg: 1200px;
@screen-lg-max: (@screen-lg - 1);
@laptop: ~"only screen and (min-width: 768px) and (max-width: @{screen-lg-max})";
@media @laptop {
color: red;
}
2
@screen-lg: 1200px;
@laptop: ~"only screen and (min-width: 768px) and (max-width:" (@screen-lg - 1) ~")";
@media @laptop {
color: red;
}
3
(Less 1.7.0):
@screen-lg: 1200px;
.laptop(@styles) {
@media screen and (min-width: 768px) and (max-width: (@screen-lg - 1)) {
@styles();
}
}
.laptop({
color: red;
});
The CSS output of all three methods will be:
@media only screen and (min-width: 768px) and (max-width: 1199px) {
color: red;
}