是有办法从css类中排除一个标签 [英] is there a way to exclude a tag from css class
问题描述
我有css的所有tr标签的表。
I have css that works on all tr tags for the table.
所以在我的html我没有样式的tr标签。然而,对于我的表中的一个TR标签,我不想应用TR是通用的所有表。有没有办法排除这个TR?
so in my html I have no styling for tr tag. However, for one TR tag in my table I do not want to apply the TR that is generic to all tables. Is there a way to exclude this 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>
有'even'或'odd'类我不想让这个< tr>
有.statisticsTable tr属性。这是可能的吗?
in above the <tr>
that has class of either 'even' or 'odd' I do not want this <tr>
to have .statisticsTable tr properties. is this possible?
主要想想我想避免是background-color:#990000;和颜色:#ffffff;
Main think I want to avoid is background-color: #990000; and color: #ffffff;
推荐答案
CSS级联,意味着您可以覆盖先前定义的属性的值。
CSS cascades, meaning you can overwrite the values of previously defined properties.
您可以:
.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;
}
如果要使用CSS3,可以使用:not 仅将以下样式应用于没有偶数或奇数类别的TR元素:
If you want to use CSS3, you can use :not to only apply the following styles to TR elements which don't have the even or odd class:
.statisticsTable tr:not(.even):not(.odd) {
font: bold 9pt Arial,Helvetica,sans-serif,Verdana,Geneva;
color: #fff;
background:#990000;
}
EDIT: ,.odd)是无效的语法,因此不会工作(至少不是在Chrome)
正确的语法是:not(selector),但是你可以做:not(selector1):not这些not()在同一级别。
not(.even,.odd) is not valid syntax thus will not work (at least not in Chrome)
correct syntax is :not(selector) , however you can do :not(selector1):not(selector2) these not()s are on the same level.
这篇关于是有办法从css类中排除一个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!