Sass和组合子选择器 [英] Sass and combined child selector
本文介绍了Sass和组合子选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚发现了Sass,我对此非常兴奋。
I've just discovered Sass, and I've been so much excited about it.
顺便说一下,在我的网站中,我实现了一个树形导航菜单,使用组合子选择器( E> F
)。
By the way, in my website I implement a tree-like navigation menu, styled using the combined child selector (E > F
).
有没有办法在Sass上重写这个代码到更简单的语法中?
Is there any way to rewrite this code into a more simpler (or better) syntax on Sass?
#foo > ul > li > ul > li > a {
color: red;
}
推荐答案
可能会做类似这样的事情:
Without the combined child selector you would probably do something similar to this:
foo {
bar {
baz {
color: red;
}
}
}
与>
具有相同的语法,您可以:
If you want to reproduce the same syntax with >
, you could to this:
foo {
> bar {
> baz {
color: red;
}
}
}
/ p>
This compiles to this:
foo > bar > baz {
color: red;
}
/ p>
Or in sass:
foo
> bar
> baz
color: red
这篇关于Sass和组合子选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文