2012-01-04 8 views
11

私のHTMLは次のとおりです。変更取り消し線テキストの色を

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

私のCSSは次のとおりです。

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

私はこの
out-put image
のように外に置く取得していますが、私がしたいですこのように
i am trying to do like this私はできません。このようにするのを手伝ってください。

+3

http://stackoverflow.com/questions/1107551/css-strikethrough-different-color- from-text –

答えて

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

元の回答へのリンクを付けるとよいでしょう。 http://stackoverflow.com/a/1107556/293712 – Maheep

+0

このリンクリファレンスは役に立ちました。ソースに信用を与えるのは良い習慣です。 – Maheep

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

+0

doesntの仕事に複数の行ががあります – martin

関連する問題