Huy Nguyen Huy Nguyen - 5 months ago 15
CSS Question

SaSS syntax for attribute with class inside?

I have style for

.post
,
.share
,
.tag
like this:

.post {
... // style for .post
}
.share {
... // style for .share
}
.post {
... //style for .tag
}


So, I want style for
a.post
,
a.share
,
a.tag
. It's any way to write it inside
.post
,
.share
,
.tag
syntax above? Or I have to write it in separate outside like:

a.post {}
a.share {}
a.tag {}

Answer

You can use string interpolation on the ampersand #{&} and also need @at-root for nested concatenated selectors.

.post {
    @at-root a#{&} {
       display: block;
    }
}

DEMO

Comments