【发布时间】:2012-06-18 07:11:56
【问题描述】:
可能重复:
How do I get this CSS text-decoration override to work?
Chrome 和 Firefox 正在密谋阻止我尝试使用直通文本装饰的 td,有时会被跨度禁用,如下所示:
<style type="text/css">
tr.st td {
text-decoration: line-through;
}
tr.st td span.unstrike{
text-decoration: none;
background:yellow;
}
tr.st td span#unstrike-id{
text-decoration: none;
background:yellow;
}
tr.st td span.unstrike-important{
text-decoration: none ! important;
background:yellow;
}
</style>
<table border>
<tbody>
<tr>
<td>normal</td>
</tr>
<tr class="st">
<td>struck out</td>
</tr>
<tr class="st">
<td>struck out <span class="unstrike">unstrike class: shouldn't I be normal?</span></td>
</tr>
<tr class="st">
<td>struck out <span id="unstrike-id">unstrike-id identifier. Shouldn't I be normal?</span></td>
</tr>
<tr class="st">
<td>struck out <span class="unstrike-important">unstrike-important: shouldn't I be even more normal?</span></td>
</tr>
</tbody>
</table>
我正盯着规范看,但我不明白。
文本修饰的特殊情况?什么给了?
演示here
【问题讨论】:
-
哇,这很有趣,似乎
text-decoration被应用于整个 TD 的内容,而忽略了它下面的任何内容。没见过。 -
查看这个答案:stackoverflow.com/a/1261974/698179 - 最好在所有
tds 中放置span,并将样式单独应用为子元素。 -
是的,我现在看到了,虽然我认为这是最好的先例:stackoverflow.com/questions/1823341/…
标签: css inheritance