我有一个以编程方式创建的 n 行的表,并且在每行上我以编程方式将一个类添加到odd
行的不同even
行中。其中一些行有一个需要突出显示的“特殊”内容,为此我在行上使用闪烁的背景:
HTML
<table>
<tr class='blink odd'>
<td>first row, very important</td>
</tr>
<tr>
<td>second row</td>
</tr>
<tr class='odd'>
<td>third row</td>
</tr>
<tr>
<td>fourth row</td>
</tr>
<tr class='odd'>
<td>fifth row</td>
</tr>
<tr class='blink'>
<td>sixth row, also important</td>
</tr>
</table>
CSS
@-webkit-keyframes 'blink' {
0% { background: rgba(255,0,0,0.5); }
50% { background: none }
100% { background: rgba(255,0,0,0.5); }
}
.blink {
-webkit-animation-direction: normal;
-webkit-animation-duration: 5s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-name: blink;
-webkit-animation-timing-function: ease;
}
table tr.odd{
background: gray;
}
我遇到的问题是闪烁行将背景从红色淡白色变为红色,而我希望它们切换背景来自红色&gt;到当前行背景颜色
例如:在奇数行上,BG应该在红色和灰色之间变换。在偶数行上,BG应该在红色和(在这种情况下)no-BG之间变换。
这可以用css实现而不设置两个关键帧(一个用于奇数,一个用于偶数行)?
谢谢