Media query with $until fails
See original GitHub issueI think I have a bug with the media queries.
The following will not work:
If I change to $from: tablet
it’s fine. Weirdly it doesn’t cause a compiler issue -but the css doesn’t seem to be output.
When trying with extend I get an error with the extend - but I think it’s related to this mixin.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Using media queries - CSS: Cascading Style Sheets | MDN
Syntax · Media types define the broad category of device for which the media query applies: all , print , screen . ·...
Read more >CSS: max-width for @media query not working
the developer tool was saying that the size of the viewport is 1400px but the actual width the css was considering was more...
Read more >Media Queries Level 4
Media Queries allow authors to test and query values or features of the user agent or display device, independent of the document being...
Read more >5 Reasons Why Your CSS Media Queries Are NOT Working ...
CSS Media queries are an important part of Responsive web design but sometimes they don't work as we expect or th...
Read more >Logic in CSS Media Queries (If / Else / And / Or / Not)
To ensure that only one media query is in effect at a time, make the numbers (or whatever) such that that is possible....
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
Thanks for investigating this @nickcolley!
OK so this is a bit of a twisty one but I think I’ve gotten to the bottom of it.
What is happening is that when the Internet Explorer 8 version of the application.css is built. It sets the
$govuk-is-ie8
variable totrue
.This then sets the
$mq-responsive
variable tofalse
.mq
is the library we use to generate our media queries. The responsive variable allows you generate a ‘desktop only’ build for older browsers, it does this by figuring out which media queries would be shown at ‘desktop only’ and removing ones on ‘mobile’.This means that when the mixin runs, it outputs nothing, which means your placeholder
%display-mobile-only
class fails to be extended because it’s empty.So you’ll see this error message:
I think the differences between compilers/wrappers is perhaps how they handle errors in this case.
I have updated my example to include the
$govuk-is-ie8: true
option and now it fails: https://glitch.com/edit/#!/govuk-frontend-issue-1674?path=src/styles/all.scss:2:0I’m have also raised an issue with sass-mq to see if we can make this better without work arounds: https://github.com/sass-mq/sass-mq/issues/130
Workaround
govuk-media-query($until)
within them, for example:or (recommended)
!optional
flag when extending, for example:I’m going to close this for now as I think this is the best I can offer at this point in time but if there’s something I’ve missed or a better way to work around this feel free to re-open, thanks 😃