将ID与CSS中的类关联

时间:2012-06-20 16:26:53

标签: css

我可以在CSS中做些聪明的事情来表明具有特定ID的元素应该总是使用一个或多个类吗?类似的东西:


#user_info_box {
    use-class: ui-widget-content ui-corner-all;
    position: fixed;
    left: 10px;
    ...
}

只知道,使用实际有效的CSS属性。

4 个答案:

答案 0 :(得分:4)

LESS非常适合这一点。具体来说,请参阅“mixins”。

#user_info_box {
    .ui-widget-content;
    .ui-corner-all;
    position: fixed;
    left: 10px;
    ...
}

答案 1 :(得分:2)

您无法在CSS中执行此操作,但您可能对SASS

感兴趣
#user_info_box {
  @extend .ui-widget-content;
  @extend .ui-corner-all;
  position: fixed;
  left: 10px;
  ...
}

答案 2 :(得分:1)

查看http://lesscss.org/

它会为您提供更多的CSS灵活性,包括类似于您所要求的内容。

答案 3 :(得分:0)

不,不。你可以使用javascript / jQuery。

相关问题