css - 如何使用 scss 父选择器来选择它的双选择器
问题描述
我来了一个场景,我想在我的 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;
}
}
}
解决方案
Not quite clear, but I think I understood you correctly.
Rules must be written in parallel ...
.parent--selector {
&.child--selector.animate {
opacity: 1;
}
&.parent--selector {
opacity: 0;
}
}
If you show your html I will say more precisely, if of course I was mistaken in this example and did not understand correctly ...
推荐阅读
- r - 在 if 语句的帮助下,让 R 在 while 循环中跳过某些索引值
- c# - 逻辑问题保存到元组
- jprofiler - 在快照比较中定位特定实例
- r - 在 R 中重塑和组合具有相似值的列
- python - 在 httpresponseredirect 中反转时,基于类的视图不返回 httpresponse?
- python - xlsxwriter“workbook.close()”python库的问题
- sql - SQL Server:批量更新触发
- visual-studio - TFS 解决方法 Check in error 找不到部分路径
- r - 如何在所有方面订购酒吧?
- bash - /usr/bin/sqlite3: 参数列表太长