我想用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;
}
}
Run Code Online (Sandbox Code Playgroud)
我基本上希望它编译为:
a.button
Run Code Online (Sandbox Code Playgroud)
这样我就可以创建如下元素:
<a class="button">
<button class="button">
Run Code Online (Sandbox Code Playgroud)
但是当它成为锚点时稍微改变它.我不想it's a bug in less!太早投入卡片,但如果我使用&.another-class它会按预期工作(编译:.button.another-class但不是在定位元素时
All*_*rgi 16
你使用的旧版本更少.下面的代码使用较少的1.3.3生成正确的CSS
.button {
a& {
height:20px;
}
}
Run Code Online (Sandbox Code Playgroud)
产生:
a.button {
height: 20px;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6893 次 |
| 最近记录: |