我有一个要求,我必须为我的表行应用条件样式,但样式永远不会被应用。
.test1 {
background-color: '#ffbf00';
}
.test2 {
background-color: '#92D050';
}
.test3 {
background-color: ' ';
}
<table id="testTable">
<tr styleClass="test1">
<td></td>
<td></td>
</tr>
</table>
但样式永远不会应用。我错过了什么?
答案 0 :(得分:2)
老兄你在这个简单的HTML代码中有10个错误。请学习HTML和CSS!以下是您可能希望以正确的方式实现的目标。
.test1 {
background-color: #ffbf00;
}
.test2 {
background-color: #92D050;
}
.test3 {
background-color: transparent;
}
&#13;
<table id="testTable">
<tr class="test1">
<td>a</td>
<td>b</td>
</tr>
</table>
&#13;
不要在颜色上加注。它意味着类,而不是styleClass。 &#39; &#39;不是有效的颜色值。等等......
答案 1 :(得分:1)
使用HTML中的定义类,不要在十六进制值周围使用引号。
.test1 {
background-color: #ffbf00;
}
.test2 {
background-color: #92D050;
}
.test3 {
background-color: ' ';
}
&#13;
<table id="testTable">
<tr class="test1">
<td>Test</td>
<td>Test</td>
</tr>
</table>
&#13;
答案 2 :(得分:0)
定位到Update(draftTask, "Cost", "500");
td
答案 3 :(得分:0)
你需要添加类名和 styleClass =&#34; test1&#34; 不正确的语法
所以更新
styleClass="test1"
到
class="test1"
还有一件事你的风格代码并不完美 所以也要更新
background-color: '#92D050';
到
background-color: #92D050;
因为这也是语法错误 其他代码还可以
.test1 {
background-color: #ffbf00;
}
.test2 {
background-color: #92D050;
}
.test3 {
background-color: rebeccapurple;
}
&#13;
<table id="testTable">
<tr class="test1">
<td>test1</td>
<td>test1</td>
</tr>
<tr class="test2">
<td>test2</td>
<td>test3</td>
</tr>
<tr class="test3">
<td>test4</td>
<td>test5</td>
</tr>
</table>
&#13;