我的桌子上有一个单元格,看起来像
<td><%= play_result.timestamp.strftime("%H:%M:%S") + ' ' + play_result.status + ':' + ' ' + '[' + play_result.host + ']' + ' ' + play_result.data %></td>
我想编写一个CSS类,该类将根据play_result.status的值来更改此单元格的字体颜色,绿色等于字符串“ OK”,橙色表示“ CHANGED”,蓝色表示“ SKIPPED”,红色表示'失败的'。
当我刚接触Rails时,该怎么做,我应该在视图中定义CSS类还是...?
首先改变你的看法:
<td class="<%= player_result.status %>">
# your code here
</td>
然后在css文件中,为每种状态类型制定规则:
.OK {
color: green;
}
.CHANGED {
color: orange;
}
.SKIPPED {
color: blue;
}
.FAILED {
color: red;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句