“text-decoration:none”无效,即使是“!important”

时间:2016-01-13 22:05:58

标签: html css text-decorations

当我尝试使用类似underline之类的内容时,它会起作用,但none不起作用,即使使用!important也是如此。有谁知道为什么?

PS: del 元素应该保留在该行中,我正在尝试从此新内容中删除该行。

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

1 个答案:

答案 0 :(得分:1)

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

**编辑**

根据进一步指示更新。此代码将从伪删除文本修饰,但不删除其余部分。关键是添加display: inline-block;

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