我正在处理HTML/CSS项目。我想根据颜色为标签和文本创建类。例如如何在存储颜色名称的Less变量中避开引号?
text-red{
color: red;
}
label-white{
color: white;
}
要做到这一点,我想创建一个接受名称和颜色作为参数的mixin并创建这个类。我写了下面的mixin:
.mixin(@name, @color) {
[email protected]{name} {
color: @color !important;
}
[email protected]{name} {
color: @color !important;
}
}
.mixin('white', white);
这给了我下面的输出
.text-'white'{ /* notice the quotes*/
color: #ffffff
}
如果我运行这个混入作为.mixin(白,白);我得到
.text-#ffffff{
color: #ffffff
}
如何使用mixin创建类似文本的类?
如果你这样做[你会有一个不好的时间](http://stackoverflow.com/questions/3687763/replacing-css-classes-with-more-generic-ones/3687819#3687819)。你也可以使用内联样式。 –
我明白了。我会考虑可能性。感谢您指出帖子。 – suparngp