SASS post固定安培和反转选择器嵌套吗?
我正在尝试探索我在互联网站上找到的以下示例。这看起来像是后固定一个符号导致SASS反转嵌套SASS post固定安培和反转选择器嵌套吗?,sass,Sass,我正在尝试探索我在互联网站上找到的以下示例。这看起来像是后固定一个符号导致SASS反转嵌套 .MyComponent { &-title { .MyComponent--xmasTheme & { } } &-content { .MyComponent--xmasTheme & { } } } // Compiles to .MyComponent-title {} .MyComponent--xmasThem
.MyComponent {
&-title {
.MyComponent--xmasTheme & {
}
}
&-content {
.MyComponent--xmasTheme & {
}
}
}
// Compiles to
.MyComponent-title {}
.MyComponent--xmasTheme .MyComponent-title {}
.MyComponent-content {}
.MyComponent--xmasTheme .MyComponent-content {}
&-title
是一个SASS功能,可以简化您的语法。它是在3.3.0rc3版本中引入的,并替换了根#{&}-title中的旧语法@at root
有关此功能的有趣文章:
.MyComponent {
&-title {
color:blue;
}
}
创建此输出:
.MyComponent-title {
color: blue;
}
而不是:
.MyComponent .MyComponent-title {
color: blue;
}
p.S.要创建最后一个输出,您可以使用插值语法编写一个安培表:
.MyComponent {
#{&}-title {
color:blue;
}
}
&-title
是一个SASS功能,可以简化您的语法。它是在3.3.0rc3版本中引入的,并替换了根#{&}-title中的旧语法@at root
有关此功能的有趣文章:
.MyComponent {
&-title {
color:blue;
}
}
创建此输出:
.MyComponent-title {
color: blue;
}
而不是:
.MyComponent .MyComponent-title {
color: blue;
}
p.S.要创建最后一个输出,您可以使用插值语法编写一个安培表:
.MyComponent {
#{&}-title {
color:blue;
}
}
我要说的是@Arkellys注释为我解答了这个问题,将SASS符号视为嵌套选择器父级的变量。因此,当符号在嵌套选择器中后固定时,SASS将输出父选择器。我要说的是@Arkellys注释为我回答了这个问题,将SASS符号视为嵌套选择器父级的变量。因此,当符号在嵌套选择器中后固定时,SASS将输出父选择器。有趣的行为,我希望得到
.MyComponent title.MyComponent--xmasteme.MyComponent title
而不是.MyComponent--xmasteme.MyComponent title
…谢谢Arkellys。由于与符号类似于保存父块的变量,因此无论与符号的位置如何,它都将输出该值。我想我很困惑,因为我把“和”读作连词,但在示例中它被用作变量。有趣的行为,我希望得到。MyComponent title.MyComponent--xmasteme.MyComponent title
而不是。MyComponent--xmasteme.MyComponent title
…啊哈,谢谢Arkellys。由于与符号类似于保存父块的变量,因此无论与符号的位置如何,它都将输出该值。我想我有点困惑,因为我把“和”读作连词,但在这个例子中它被用作变量。谢谢你的解释。在我发布的示例中,似乎post修复了符号并否定了插值语法的需要。感谢您的解释。在我发布的示例中,似乎post修复了符号并否定了插值语法的需要。