28 css
我有css适用于表的所有tr标签.
所以在我的HTML中,我没有tr标签的样式.但是,对于我表中的一个TR标记,我不想对所有表应用通用的TR.有没有办法排除这个TR?
.statisticsTable {
border:2px solid #990000;
width:100%;
}
.statisticsTable tr {
font-weight : bold;
font-size : 9pt;
font-family : Arial,Helvetica,sans-serif,Verdana,Geneva;
color: #ffffff;
background-color:#990000;
}
<table class="statisticsTable">
<tr><td colspan="7" class="tableHeaderText">HUB Statistics</td></tr>
<tr>
<th colspan="2">HUB</th>
<th >House Houlds Evaluated</th>
<th >Total Debt Owed</th>
</tr>
<tr class="<s:if test="#status.even">even</s:if><s:else>odd</s:else>">
<td rowspan=3 valign=top>213-65-6425</td>
<td >All</td>
<td >t1</td>
<td >t2</td>
Run Code Online (Sandbox Code Playgroud)
在上面<tr>有'偶数'或'奇数'的类我不希望它<tr>有.statisticsTable tr属性.这可能吗?
主要认为我想避免的是背景颜色:#990000; 和颜色:#ffffff;
Nic*_*sta 42
CSS级联,意味着您可以覆盖先前定义的属性的值.
你会这样做:
.statisticsTable tr.even, .statisticsTable tr.odd {
font-weight: normal;
font-size: DEFAULT; /* what ever your default is */
font-family: DEFAULT; /* what ever your default is */
/* I would use the font shorthand property */
color: DEFAULT;
background: DEFAULT;
}
Run Code Online (Sandbox Code Playgroud)
如果你想使用CSS3,你可以使用:不要只将以下样式应用于没有偶数或奇数类的TR元素:
.statisticsTable tr:not(.even):not(.odd) {
font: bold 9pt Arial,Helvetica,sans-serif,Verdana,Geneva;
color: #fff;
background:#990000;
}
Run Code Online (Sandbox Code Playgroud)
编辑: 不(.even,.odd)是无效的语法因此不起作用(至少不在Chrome中)正确的语法是:not(selector),但是你可以这样做:not(selector1):not(selector2)这些不是()s在同一水平上.