Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting current element in Sass

Tags:

sass

Does Sass have a selector to refer to the element at the current nesting level? That way duplication like this could be avoided:

.something {
    color: red;
    a {
        color: red; // a tags are already styled globally
    }
}

And I could write this instead.

.something {
    self, a {
        color: red;
    }
}
like image 893
Matt Zeunert Avatar asked Mar 21 '23 00:03

Matt Zeunert


1 Answers

There is a good new feature in the Sass 3.3 - @at_root

.something {
    &, a {
        color: red;
    }
 }

More variants of using this feature you can find here:

https://github.com/nex3/sass/issues/774

like image 142
Slawa Eremin Avatar answered Apr 25 '23 23:04

Slawa Eremin