我正在尝试删除应用于我的元素的 text-decoration:line-through;
样式,但我似乎无法这样做。我试过 text-decoration:none;
但它不起作用。
当我将 text-decoration:underline;
应用于 span
时,浏览器似乎没有替换 line-through
样式而是添加了underline
样式。
我知道我总是可以重新编写我的 HTML,以便需要 line-through
的元素有自己的类。我想知道除了重构我的 HTML 之外是否还有其他选择。
<style>
p { text-decoration:line-through; }
span { text-decoration:none; }
</style>
<p>Foo <span>bar</span></p>
最佳答案
I know I can always re-write my HTML so the elements that require a
line-through
has their own class. I'm wondering if there is an alternative other then restructuring my HTML.
不是真的。你看到的行为完全是by design ;祖先将始终将他们的文本装饰传播给某些后代,相反,您不能从后代内部影响祖先的文本装饰。
尽管text-decoration-skip
from the upcoming CSS3 text decoration module,目前没有非常可行的重组替代方案。看起来很有前途。
关于html - 如何删除 CSS line-through,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13693866/