由于CSS特异性问题,我试图构建一个包含较少混联的CSS表达式,如下所示:
// overriding any previous styling with a more specific expression:
.styleSpecificListElement(@id: "#index") {
main .list ul @{id} a {
// referencing another mixin here:
.setLiStyling();
}
}LESS将解析这一点,但是它是用双引号中插入的参数进行解析的,在双引号中不按预期进行计算:
/* don't want the double-quotes around the id: */
main .list ul "#index" a {
/* ...code from the .setLiStyling() mixin generated here... */
}发布于 2014-01-02 03:02:01
好吧,没关系,我刚刚算出来了--散列符号#可以放在@{id}引用的前面,然后参数作为一个没有引号的字符串传递:
.styleSpecificListElement(@id: index) {
main .list ul #@{id} a {
// referencing another mixin here:
.setLiStyling();
}
}然后,...where调用.styleSpecificListElement(foobar)将解析为:
main .list ul #foobar a {
/* ...code from the .setLiStyling() mixin generated here... */
}https://stackoverflow.com/questions/20875505
复制相似问题