css设置文字删除线
时间:2021-05-07
来源:互联网
标签:
今天PHP爱好者为您带来在css中可以通过给文字设置“text-decoration: line-through;”属性来实现删除线效果;“text-decoration”属性用于“装饰”文本的内容,可以为所选文本添加下划线、上划线、直线或组合线。希望对大家有所帮助。

css设置文字删除线
本文操作环境:windows7系统、HTML5&&CSS3版、Dell G3电脑。
想要使用CSS实现文字删除线效果,可以使用text-decoration属性,将其设置为line-through值即可。text-decoration属性用于“装饰”文本的内容,可以为所选文本添加下划线,上划线,直线或组合线;它本质上是用不同种类的行来装饰文本。
text-decoration属性规定添加到文本的修饰,其中修饰的颜色由 "color" 属性设置。这个属性允许对文本设置某种效果,如加下划线。如果后代元素没有自己的装饰,祖先元素上设置的装饰会“延伸”到后代元素中。
语法:
text-decoration: none|underline|overline|line-through|blink|inherit;
属性值:
● none:默认,定义标准的文本;不绘制任何线条,并删除任何现有装饰。
● underline:绘制文本下的一条1px线。
● overline:绘制文本顶部的一条1px线。
● line-through:在文本的“中间”点绘制1px线,即绘制穿过文本下的一条线。
● blink:定义闪烁的文本。注:该值在W3C规范中,但已弃用,不适用于任何当前浏览器;当它工作时,通过在0%和100%不透明度之间快速切换,使文本看起来“闪烁”。
● inherit:继承父级 text-decoration 属性的值。
text-decoration作为速记属性
text-decoration可以与text-decoration-line、text-decoration-style和text-decoration-color组合使用,作为一个速记属性
.fancy-underline {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: red;
/* can be shortened to */
text-decoration: underline wavy red;
}
示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
.underline {
text-decoration: underline;
}
.overline {
text-decoration: overline;
}
.strikethrough {
text-decoration: line-through;
}
.multiple {
text-decoration: underline overline line-through;
}
.blink {
text-decoration: blink;
}
.wavy {
text-decoration: red underline overline wavy;
}
body {
padding: 1em 2em;
}
</style>
</head>
<body style="text-align:center">
<p class="underline">text-decoration: underline;</p>
<p class="overline">text-decoration: overline;</p>
<p class="strikethrough">text-decoration: line-through;</p>
<p class="multiple">text-decoration: underline overline line-through;</p>
<p class="blink">text-decoration: blink;</p>
<p class="wavy">text-decoration: red underline overline wavy;</p>
</body>
</html>
效果图:

从上例可以看出,可以将underline,overline或line-through组合在一个以空格分隔的列表中,以添加多个装饰线效果。
以上就是css设置文字删除线的详细内容,更多请关注php爱好者其它相关文章!
-
什么是启发式算法 启发式算法有哪几种 启发式算法的特点 时间:2025-11-01 -
MySQL convert函数用法详解 时间:2025-11-01 -
Linux中cpio命令保存文件权限设置步骤详解 时间:2025-11-01 -
中间人攻击(MITM)有哪些方式 中间人攻击的防护措施有哪些 时间:2025-11-01 -
什么是中间人攻击(MITM) 中间人攻击原理 如何防止中间人攻击 时间:2025-11-01 -
commons-fileupload实现文件上传的基本步骤 时间:2025-11-01
今日更新
-
HFT币2026年购买指南 欧易App交易教程与投资策略
阅读:18
-
幣安binance(币安)国内无法下载?华为手机一键安装幣安binance(币安)国际版教程
阅读:18
-
摸鱼师傅是什么梗 职场人秒懂的带薪划水暗号
阅读:18
-
HFT币2026年价格预测 币安App最新走势分析报告
阅读:18
-
华为手机安装幣安binance(币安)提示危险怎么办?华为手机安装幣安binance(币安)被拦截
阅读:18
-
PENDLE币2026投资指南 欧易App注册及买入步骤详解
阅读:18
-
想知道师娘是什么梗?揭秘网络热词师娘的爆笑由来和最新用法!
阅读:18
-
PENDLE币2026价格预测 币安App最新趋势与投资分析
阅读:18
-
华为手机安装幣安binance(币安)提示危险怎么办?详细解决方法来了!
阅读:18
-
石榴是什么梗?揭秘网络热词石榴的爆笑由来和流行用法!
阅读:18










