我有css特异性问题。悬停的css特异性
我想<td>
风格如果有'没有条例草案'是不同的颜色,所以我用if语句设置样式。如果没有账单,则样式为style = "id=\"no-bills\"";
。我得到这个与CSS一起工作。现在,如果用户悬停在它上面,我希望背景变红 - 所以我修改了css并添加了#bill-list #no-bills td:hover
,其中有td:hover
在将鼠标悬停在其上时会添加一些额外的特性。不幸的是,这不起作用(背景保持不变)。
这里是我的CSS:
#bill-list
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
/*margin: 45px;*/
width: 100%;
text-align: left;
border-collapse: collapse;
}
#bill-list th
{
font-size: 13px;
font-weight: normal;
padding: 8px;
background: #b9c9fe;
border-top: 4px solid #aabcfe;
border-bottom: 1px solid #fff;
color: #039;
}
#bill-list td
{
padding: 8px;
background: #e8edff;
border-bottom: 1px solid #fff;
color: #669;
border-top: 1px solid transparent;
}
#bill-list tr:hover td
{
background: #d0dafd;
color: #339;
}
#bill-list #bill td
{
background: white;
}
#bill-list #no-bills
{
background: #FFCC99;
}
#bill-list #no-bills td:hover
{
color: orange;
background: red /*#FFCC66*/;
}
这里是我的代码(片段):
<table id="bill-list">
<thead>
<tr>
<% for (int i=0; i<vecHeader.size(); i++) { %>
<th><%=vecHeader.get(i) %></th>
<% } %>
</tr>
</thead>
<tbody>
<% int uniqueId = 0;
for (int i=0; i < vecValue.size(); i++) {
boolean hasBills = true;
String style = "";
if (vecBills.get(i) == null || vecBills.get(i).size() == 0) {
hasBills = false;
style = "id=\"no-bills\"";
}
%>
<tr id="bill<%=i%>" onclick="javascript:showBillDetails(<%=i%>)">
<% for (int j=0; j < vecHeader.size(); j++) {
prop = (Properties)vecValue.get(i);
%>
<td <%=style%>><%=prop.getProperty((String)vecHeader.get(j), " ") %> </td>
<% } %>
</tr>
...
...
人有什么想法?
做了诡计 - 谢谢! (是的,我应该发布html)。 – Jarrett 2012-07-25 20:03:30