【问题标题】:Change strike-through text color in css [duplicate]在css中更改删除线文本颜色[重复]
【发布时间】:2013-10-04 13:34:13
【问题描述】:

我的html是:

<html>  
<body>  
     <div id="example">this is example</div>  
</body>  
<html>

我的css是:

#example{text-decoration: line-through;color:#ccc;} 

我得到这样的输出

但我想要这样
但我不能.帮我这样做。

【问题讨论】:

标签: html css


【解决方案1】:

颜色适用于线条和文本。你需要像嵌套一样。

<span style="text-decoration: line-through; color: red;">
 <span style="color: #CCC;">text with red linethrough and black text</span>
</span>

来源:http://www.savio.no/artikler/a/335/different-font-color-than-line-through-color-with-css

【讨论】:

  • 如果您提供原始答案的链接会很好。 stackoverflow.com/a/1107556/293712
  • 那么这个链接参考会有所帮助。将功劳归于来源是一个好习惯。
  • 没有不好的感觉。它不仅与信用有关。在这种情况下,参考是一篇非常好的文章,不仅说明了如何做到这一点,而且还有缺点等,这将有很大帮助。
  • strike 或 del html 标签看起来更干净:  facebook  
【解决方案2】:

这是一个例子,它可以正常工作。

HTML:

<div id="example">
    this is example
    <span></span>
</div>

CSS:

#example{
    color:#ccc;
    font-size: 20px;
    position: relative;
    display: inline-block;
}

#example span {
    position: absolute;
    width: 100%;
    border-top: 1px solid red;
    left: 0;
    top: 50%;
}

http://jsfiddle.net/amkrtchyan/RHPHX/1/

【讨论】:

  • 在多行时不起作用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-30
  • 1970-01-01
  • 2013-02-19
  • 1970-01-01
  • 2016-10-22
相关资源
最近更新 更多