我抛出了一个场景,我想在我的 sass 中引用我的父选择器,稍后我想将父选择器添加到它的双选择器 animate
以在滚动时执行某个动画。有什么办法可以实现它。任何帮助,将不胜感激。我知道解释我的问题很棘手。希望下面的例子能解释我的需要。
CSS
.parent--selector.animate .child-selector {
opacity: 1;
}
.parent--selector .child--selector {
opacity:0;
transition: 0.3s;
}
我想使用具有以下模式的 scss 实现上述样式
SCSS
.child--selector {
opacity: 0;
transition: 0.3s;
.parent--selector & {
&.animate {
opacity: 1;
}
}
}
最佳答案
不太清楚,但我想我理解正确。
规则必须并行编写...
.parent--selector {
&.child--selector.animate {
opacity: 1;
}
&.parent--selector {
opacity: 0;
}
}
如果你展示你的 html 我会更准确地说,如果我在这个例子中弄错了并且没有正确理解......
关于css - 如何使用 scss 父选择器来选择它的双重选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54664454/