2012-08-15 11 views
1

我想练习我的CSS(眨眼)干,我卡在如何解决这个问题。如何指定可以匹配给定选择器的多个类?

如何减少这样的:

table.shipmentItemList TD.title, 
table.shipmentItemList TD.author, 
table.shipmentItemList TD.options { 
    font-size: 1.0em; 
    font-weight: normal; 
} 

为了这样的事情:

table.shipmentItemList TD.title, TD.author, TD.options { 
    font-size: 1.0em; 
    font-weight: normal; 
} 

或者更好的是这样的:

table.shipmentItemList TD .title, .author, .options { 
    font-size: 1.0em; 
    font-weight: normal; 
} 
+0

如果你希望做那种在CSS中的事情,你将不得不看看LESS或SASS。由于你的代码在标准的CSS中表现的非常好。 – Kyle 2012-08-15 12:57:57

回答

0

看一看LESS,或LESS PHP如果你宁愿做它的服务器上。你问的是用vanilla CSS不可能的。

你的榜样应该是这样的:

table.shipmentItemList { 
    td { 
     &.title, &.author, &.options { 
      font-size: 1.0em; 
      font-weight: normal; 
     } 
    } 
} 
0

看看less.js它会让你做这样的事情:

table.shipmentItemList{ 
    TD.title, TD.author, TD.options { 
    font-size: 1.0em; 
    font-weight: normal; 
    } 
} 
相关问题