我想使用less来针对类中的特定元素。
在这种情况下,我想针对类button
中的一个锚点标签a
。
目前我有:
.button {
/* lots of bits and pieces go here, hence
the need to keep it at a class level
*/
/* further down, but still in .button */
/* Attempt 1 - fails: compiled = a .button (note the space)
a& {
height:20px;
}
/* Attempt 2 - fails: compiled = .buttona
&a {
height:20px;
}
}
我基本上希望它可以编译成:
a.button
这样我就可以创建诸如:
<a class="button">
<button class="button">
但是当它是一个锚点时,稍微改变一下。我不想太早就扔出“这是Less中的一个bug!”的牌子,但如果我使用&.another-class
,它会像预期的那样工作(编译后为.button.another-class
),但是如果针对元素,则不起作用。