在css中更改删除线的文本颜色

时间:2012-01-04 08:16:18

标签: html css

我的HTML是:

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

我的css是:

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

我这样做了
out-put image 但我想这样
{{0但我不能。请帮我这样做。

2 个答案:

答案 0 :(得分:20)

颜色适用于直通和文字。你需要像窝一样。

<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

答案 1 :(得分:0)

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

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

相关问题