CSS中的文字中划线是通过text-decoration属性实现的。该属性用于设置文本的装饰效果,如删除线、下划线、上划线等。
none:默认值,无装饰。underline:添加下划线。overline:添加上划线。line-through:添加删除线(中划线)。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Text Decoration</title>
<style>
.strikethrough {
text-decoration: line-through;
}
</style>
</head>
<body>
<p>这是一段普通的文本。</p>
<p class="strikethrough">这是一段带有删除线的文本。</p>
</body>
</html>text-decoration属性值拼写错误。text-decoration属性值拼写正确。:hover、:active等。a:hover {
text-decoration: line-through;
}text-decoration属性设置为none。.strikethrough {
text-decoration: none;
}通过以上方法,可以有效地使用CSS实现文字中划线效果,并解决常见的相关问题。