如何在 LessCSS 中只嵌套一层?
我正在尝试
li > a
使用 LessCSS 嵌套。这可能吗?
我最初以为可能是这样的
li {
> a { }
}
,但这没有用。有什么想法吗?
I'm trying to do
li > a
with LessCSS nesting. Is this possible?
I initially thought maybe something like
li {
> a { }
}
But this didn't work. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来应该可以工作,但是尝试在组合器之前添加一个
&
:LESS 网站 没有提到在将选择器与其他组合器嵌套时使用
&
,但话又说回来,那里的文档并不是我见过的最好的。It looks like that should work, but try adding an
&
just before the combinator:The LESS web site doesn't mention the use of
&
when nesting selectors with other combinators, but then again the documentation there isn't the best I've seen.LESS CSS 网站没有提到这些事情,这很令人困惑。但实际上所有类型的选择器都可以工作(即使没有 & 符号)。您可以输入任何 CSS 选择器,它们将正确编译:
在为伪类/元素编写规则时需要 & 符号:
您确定它不起作用吗?您使用的是最新版本的 LESS 吗?
The LESS CSS website doesn't mention these things which is quite confusing. But all kinds of selectors actually work (even without the & sign). You can type any of the CSS selectors and they will compile properly:
You need the & sign when writing rules for psedudo-classes/elements:
Are you sure it's not working? Are you using the latest version of LESS?