html - 如何删除 CSS line-through

标签 html css

我正在尝试删除应用于我的元素的 text-decoration:line-through; 样式,但我似乎无法这样做。我试过 text-decoration:none; 但它不起作用。

当我将 text-decoration:underline; 应用于 span 时,浏览器似乎没有替换 line-through 样式而是添加了underline 样式。

我知道我总是可以重新编写我的 HTML,以便需要 line-through 的元素有自己的类。我想知道除了重构我的 HTML 之外是否还有其他选择。

http://jsfiddle.net/wshHW/

<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/

相关文章:

javascript - 从 iframe HTML 传递 token 的解决方案

javascript - margin-top 在 Internet Explorer 中工作但不在谷歌浏览器中工作

jquery - 如何验证 jquery 中的单选按钮?

css - 鼠标移出时图标旋转

html - 将 div 的宽度限制为父宽度,否则使用椭圆

html - 如何更改 nav ul li 颜色?

asp.net - HTML5 离线存储 - session 的替代方案?

html - Bootstrap 3 表 - 表响应不起作用

jquery - 下拉菜单,如 http ://www. teslamotors.com/

jquery - 如何启用AJAX登录时记住密码?