本文介绍了在SCSS中嵌套元素+元素选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为SCSS的新手,我想知道如何使用它的嵌套,用于 选择器。通常,在CSS中,我会写如下:
As a newbie in SCSS I am wondering how to use its nesting for the element + element selector of CSS. Normally, in CSS, I would write something like:
.test{
color: red;
}
.test + label{
color: blue;
}
如何嵌套 + label
selector .test
选择器?提前感谢!
How can I nest the + label
selector inside the .test
selector? Thanks in advance!
推荐答案
Upate:在这种情况下,所有您需要做的是嵌套规则像这样:
Upate: In this case all you need to do is to nest rules like this:
.test {
color: red;
+ label {
color: blue;
}
}
但是,您也可以使用&
选择器来实现这样的效果:
However, you can also use the &
selector to achieve the same effect like this:
.test {
color: red;
& +label {
color: blue;
}
}
这篇关于在SCSS中嵌套元素+元素选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!