2012-01-04 26 views
11

Mi html es:Cambiar el color del texto tachado en css

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

Mi css es:

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

me estoy fuera puse como esto
out-put image
pero quiero como este
i am trying to do like this pero no puedo. Ayúdame a hacer así.

+3

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

Respuesta

20

El color se aplica a la línea y al texto. Necesitas anidar como.

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

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

+1

Sería bueno dar un enlace a la respuesta original. http://stackoverflow.com/a/1107556/293712 – Maheep

+0

Entonces esta referencia de enlace habría ayudado. Es un buen hábito dar crédito a la fuente. – Maheep

+1

respuesta actualizada. –

0

Este es un ejemplo, funciona correctamente.

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

no funciona cuando hay más de una línea, aunque – martin

Cuestiones relacionadas