Media queries: parentheses needed even without --strict-math=on
See original GitHub issueThis example produces different output under less 1.3.3 and 1.4.2:
.foo (@dpr) {
@dpi: @dpr * 96dpi;
@query: ~'(min-resolution: @{dpi})';
@media @query {
}
}
.foo(2);
Output with less 1.3.3:
@media (min-resolution: 192dpi) {
}
Output with less 1.4.1:
@media (min-resolution: 2 * 96dpi) {
}
Adding parentheses around @dpr * 96dpi
makes less 1.4.1 output the same as 1.3.3, but this was an unexpected gotcha with the upgrade to 1.4.x.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Using media queries - CSS: Cascading Style Sheets | MDN
Each media feature expression must be surrounded by parentheses. Logical operators can be used to compose a complex media query: not , and...
Read more >Media Queries With or Without Brackets - Litmus
This bug was fixed by Yahoo in march 2015, and is no longer required. You can now safely use classes selectors in an...
Read more >A Complete Guide to CSS Media Queries
CSS Media queries are a way to target browser by certain characteristics, features, and user preferences, then apply styles based on those ...
Read more >How do I nest and/or statements in a CSS media query?
"or" is expressed with a comma separating two or more entire media queries; "and" with the and keyword within each media query separating ......
Read more >You Probably Don't Need Media Queries Anymore
They've been around for a minute, with grid hitting full browser support in 2017 and flexbox in 2013, but a lot of folks...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
👍 Also seeing this on less 2.5.1. The suggested workaround of putting parenthesis around the variable in the media query works.
Trivial problem case:
Compiled CSS of trivial problem case (invalid):
Trivial problem case with workaround:
Compiled CSS of trivial problem case with workaround:
You’re mixin up
@sm -1
and@sm - 1
(the first one is not an arithmetic expression but a two value list).