[英]Multiple CSS classes with Less
I am fairly new Less and have been trying to get a jQuery plugin to work with my custom CSS generated via Less. 我是新来的Less,一直在尝试让jQuery插件与通过Less生成的自定义CSS一起使用。 Basically, what I have is the following html generated by a plugin:
基本上,我所拥有的是由插件生成的以下html:
<div class="classA class B" ....>
<div class="classC classD" ....>
<div class="classE classF" ....>
..........
I am not sure how to structure my Less file in order to generate CSS that matches the above. 我不确定如何构造我的Less文件以便生成与上述内容匹配的CSS。
I have tried: 我努力了:
.classA {
......
&.classB {
.....
&.classC {
....and so on
but it generates the following CSS: 但它会生成以下CSS:
.classA {...}
.classA.classB {....} /*This does not include the CSS of classA */
.classA.classB.classC {.....} /*This does not include CSS of classA or classB*/
...
The plain CSS is fairly easy to write : 普通的CSS相当容易编写:
.classA {.....}
.classB {.....}
and when I write how do I achieve the above using Less? 当我写时如何使用Less实现以上目标? Is there a simple way to achieve this without using functions or extends?
是否有一种不使用功能或扩展的简单方法来实现这一目标?
Nesting elements in less has the result you're describing when adding the &
: you specify the selector that uniquely matches with that parent and child class (.classA.classB in CSS ), 在添加
&
时,将less嵌套元素会得到您要描述的结果:指定与该父级和子级(CSS中的.classA.classB)唯一匹配的选择器,
to do what you're asking 去做你要问的
.classA {.....}
.classB {.....}
you simply shouldn't nest_ 你根本不应该nest_
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.