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实现文字中划线效果,并解决常见的相关问题。
领取专属 10元无门槛券
手把手带您无忧上云