css - 内部类的属性的 SaSS 语法?

标签 css sass css-selectors

我有 .post.share.tag 的样式,如下所示:

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

所以,我想要 a.posta.sharea.tag 的样式。上面的.post, .share, .tag 语法里面有什么办法可以写吗?或者我必须把它写在单独的外面,比如:

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

最佳答案

您可以在与号 #{&} 上使用字符串插值,还需要 @at-root 用于嵌套的串联选择器。

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

DEMO

关于css - 内部类的属性的 SaSS 语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38136548/

相关文章:

css last-child 匹配所有 child

jquery onclick 下拉菜单

javascript - 2个div在qtip1中彼此相邻

css - javascript可以像在LESS中一样写在SCSS文件中吗?

css - 在哪里定义体型

html - CSS :selectors animation stops working correctly after removing "required" tag from input field

html - CSS : When to use display flex and display inline-block?

html - 是否可以在不使用 JavaScript 的情况下在窗口调整大小时调整 div 的大小?

sass - Sass 3.3与Compass兼容吗?

css - 将条件 CSS 选择器应用于 magento 属性