【问题标题】:"text-decoration: none" not working, even with "!important"“文本装饰:无”不起作用,即使使用“!重要”
【发布时间】:2016-01-13 22:05:58
【问题描述】:

当我尝试使用underline 之类的东西时,它可以工作,但none 不能,即使使用!important。有谁知道为什么?

PS:del 元素应该与该行保持一致,我正在尝试从这个新的 after 内容中删除该行。

del:after {
  content: attr(datetime);
  text-decoration: none !important;
}
<del datetime="2001-01-01">Text</del>

【问题讨论】:

  • TEXT2001-01-01 是 TEXT 是 del 元素 而 2001-01-01 是伪元素的结果.. 这个问题不是问题

标签: html css text-decorations


【解决方案1】:

您需要定位<del> 元素本身,而不是:after 伪元素。

** 编辑 **

根据进一步说明进行了更新。此代码将从伪中删除文本装饰,但不会删除其余部分。关键是添加display: inline-block;

del:after {
  display: inline-block;
  content: attr(datetime);
  text-decoration: none;
}
<del datetime="2001-01-01">Text</del>

【讨论】:

  • 但我只想要不带行的日期。其余的应该留在这条线上。
  • 是的,但我认为这是一种简单正确的css方式,而不是使用span,因为使用它我必须使用 所有句子并在之后使用del span { text-decoration: line-though }使用text-decoration: none。听起来很愚蠢。
  • @Hugo 道歉,我弄错了。我很快就会更新我的示例。
  • @Hugo 更新了答案,尽管我不完全确定为什么在这种情况下需要 display: inline-block;
猜你喜欢
  • 2018-02-09
  • 1970-01-01
  • 2012-05-10
  • 2020-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-28
相关资源
最近更新 更多