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.

Make @extend available for nested selectors

See original GitHub issue

Hi,

currently if you try to extend a class, for example #content input it will throw a error like: “Syntax error: Can’t extend #content input: can’t extend nested selectors”.

It would be great if that would be available!

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
whaaaleycommented, Sep 18, 2014

I think the best way to fix the problem your having is by using a placeholder like this:

%blue {
    color: blue;
    font-weight: bold;
}

#content {
    input {
        @extend %blue;
    }
}

.content-other {
    .content-nested {
        @extend %blue;
    }
}

I think extending nested selectors would get confusing easily. By using a placeholder it also makes it available if you ever want to use it again without having to remember that the styles you want to use are in #content input

See these issues for explanations: #609 and #251.

0reactions
chriseppsteincommented, Sep 18, 2014

@dustindowell22 nailed this. The rationale is that if you need to extend a modified thing, that thing is worth naming and extracting to it’s own concept.

Read more comments on GitHub >

github_iconTop Results From Across the Web

css - Extend function doesn't work with nested selectors
When using extend feature to extend nested selectors, an exactly matching selector (full selector path) should be provided (or) the all keyword ...
Read more >
Sass: @extend
Sass's @extend rule solves this. It's written @extend <selector> , and it tells Sass that one selector should inherit the styles of another....
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 >
LESS - Extending Nested Selectors - Tutorialspoint
Nested selectors are matched using the extend selector. Example. The following example demonstrates the use of extending nested selectors in the LESS file...
Read more >
Grouping and Nesting CSS Selectors: CSS Tutorial - Sabe.io
It's that simple. To nest a selector, you simply separate them with a space. But what if you had a third paragraph tag...
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