2015-02-08 41 views
0

我有一个类别列表,每个类别在我的主页上都有自己的标签和图标。每个类别标签/图标应该是独特的颜色。编辑特定类别的css

这是通过HTML简单:

<!-- ngRepeat: category in categories | orderBy:'display_priority' --> 
<a ng-href="explore?category=53" ng-repeat="category in categories | orderBy: 
'display_priority'" class="ui random-color item large label ng-binding ng-scope" 
ng-show="hasCategory" href="explore?category=53" style="color:red";> 

的UI是处于开发阶段,这个HTML擦拭每个UI更新(定期)。因此,我试图通过CSS实现相同的结果。

我可以用这个代码更改分类标签一般的颜色(即让他们都相同的颜色):

#front-page .ui.label { 
color: #XYZ 
} 

是否有可能对我来说,通过CSS改变每个标签的颜色单独纯粹?

回答

0

如果类别的数量是有限的,那么你可以使用一组CSS3第n个孩子的伪类来做到这一点:通过枚举类DOM

http://www.sitepoint.com/web-foundations/understanding-nth-child-pseudo-class-expressions/

你也可以用JavaScript做动态循环中的元素,然后设置元素的CSS颜色。

+0

谢谢,nth-child伪类似乎是一种可能的解决方案,我正在研究它。 – 2015-02-08 04:26:26

+0

工作。非常感谢,谢谢。 – 2015-02-08 04:51:11