在CSS中将ID与类别相关联
问题描述:
我可以在CSS中做些聪明的事情来指示具有特定ID的元素应始终使用一个或多个类吗?像这样:
Is there something clever I can do in CSS to indicate that an element with a particular ID should always use one or more classes? Something like:
#user_info_box {
use-class: ui-widget-content ui-corner-all;
position: fixed;
left: 10px;
...
}
只有您知道,使用的是实际有效的CSS属性.
Only, you know, using actual valid CSS properties.
答
LESS 非常适合.具体来说,请参见"mixins".
LESS is perfect for this. Specifically, see "mixins".
#user_info_box {
.ui-widget-content;
.ui-corner-all;
position: fixed;
left: 10px;
...
}