Sass and combined child selector(Sass 和组合子选择器)
问题描述
我刚刚发现了 Sass,对此我感到非常兴奋.
I've just discovered Sass, and I've been so excited about it.
在我的网站中,我实现了一个树状导航菜单,使用 子组合子 (E > F
).
In my website I implement a tree-like navigation menu, styled using the child combinator (E > F
).
有没有办法在 Sass 中用更简单(或更好)的语法重写这段代码?
Is there any way to rewrite this code with a simpler (or better) syntax in 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;
}
}
}
编译成这样:
foo > bar > baz {
color: red;
}
<小时>
或者在 sass 中:
Or in sass:
foo
> bar
> baz
color: red
这篇关于Sass 和组合子选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Sass 和组合子选择器


基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01