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.

selector inside Nested @media

See original GitHub issue
@media screen
  .test
   .widget 
     padding 10px;
     @media (min-width: 600px) 
       .inner
         padding 20px

yeild to

@media screen {
  .test .widget {
    padding: 10px;
  }
}
@media screen and (min-width: 600px) {
  .inner {
    padding: 20px;
  }
}

instead of:

@media screen {
   .test .widget {
     padding: 10px;
   }
 }
 @media screen and (min-width: 600px) {
   .test .widget .inner {
     padding: 20px;
   }
 }

it may be related to #1882 , however I tested with the patch @5ee7c0e0850 , and it did not fixed.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kizucommented, Dec 14, 2015

We’ll fix this eventually, for the time being you can use this workaround mixin:

media($query)
  @media $query
    /{selector()}
      {block}

Used like this:

+media('screen')
  .test
    .widget
      padding: 10px

      +media('(min-width: 600px)')
        .inner
          padding: 20px

it would render as desired:

@media screen {
  .test .widget {
    padding: 10px;
  }
}
@media screen and (min-width: 600px) {
  .test .widget .inner {
    padding: 20px;
  }
}
1reaction
opl-commented, Sep 5, 2017

Bump, just encountered this issue too. @kizu When’s the “eventually”? Been 2 years already. 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested Media Queries - CSS-Tricks
But I've digressed before I even began. You can nest media queries in native CSS, as long as you're doing it from the...
Read more >
How to get a SASS nested nested media query to work with ...
I am trying to get a nested IE10+ media query to work in SASS and am not understanding the output. I think that...
Read more >
Nested Media Queries - Bram.us
‍♂️ Don't confuse Nested Media Queries with CSS Nesting, an upcoming feature of CSS, which allows you to nest selectors. UPDATE: Thanks to ......
Read more >
CSS Nesting Module - W3C
This module introduces the ability to nest one style rule inside another, with the selector of the child rule relative to the selector...
Read more >
Nesting Media Queries (How To) | Sass Basics - Treehouse
Sass lets you nest media queries directly inside the initial rules you're modifying. This keeps media queries local to the original selector, ...
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