question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Style JSX is not working properly with @media-query

See original GitHub issue

Bug report

Describe the bug

I am using <style jsx> to style my components. When that code is compiled @media query isn’t executed successfully.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

.post__card .summary {
   width: 351px;
}

@media screen and(max-width: 1142px) {
   .post__card .summary {
       width: 80%;
   }
}

Expected behavior

When code is compiled I have jsx-2993501484 post__card and jsx-2993501484 summary and JS is looking for

@media screen and(max-width:1142px) {
    .post__card.jsx-2993501484 .summary.jsx-2993501484 {
        width: 80%;
    }
}

But for some reason style from @media-query is not applied to the element. That part of CSS is not even available in Inspect element in browser

Screenshots

bug2 bug

System information

  • OS: Manjaro Linux
  • Browser: Chrome
  • Version of Next.js: ^9.1.8-canary.13

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
M1ck0commented, Feb 13, 2020

Goddammit. I am so stupid. Thank you a lot. A lot

1reaction
jamesmosiercommented, Feb 13, 2020

You need to add a space to your media query between and and (:

@media screen and (max-width: 1142px) {
Read more comments on GitHub >

github_iconTop Results From Across the Web

Style JSX is not working properly with @media-query in NextJS
This is the current code @media screen and(max-width: 1142px) { .post__card .summary { width: 80%; } }. This is fixed code
Read more >
Beginner's guide to media queries - Learn web development
The CSS Media Query gives you a way to apply CSS only when the browser ... well in this orientation may not work...
Read more >
'Nested style detected' when dynamically including a media ...
'Nested style detected' when dynamically including a media query in a ... Unfortunately nesting is not supported by styled-jsx. at Function.
Read more >
Why is my React stylesheet media query not working?-Reactjs
[Solved]-Why is my React stylesheet media query not working?-Reactjs. Search. score:1. Accepted answer. import React from "react"; import { useMediaQuery } ...
Read more >
Using CSS media queries in React with Fresnel
Fresnel transfers the traditional media query approach to the React ... The above example would work fine unless you need to implement a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found