CSS text-decoration 属性

目录
文章目录隐藏
  1. 属性定义及使用说明
  2. 属性值
  3. 浏览器支持
  4. 实例 1
  5. 实例 2
  6. 相关文章

属性定义及使用说明

text-decoration 属性规定添加到文本的修饰,下划线、上划线、删除线等。

text-decoration 属性是以下三种属性的简写:

语法

/*关键值*/
text-decoration: none;                     /*没有文本装饰*/
text-decoration: underline red;            /*红色下划线*/
text-decoration: underline wavy red;       /*红色波浪形下划线*/

/*全局值*/
text-decoration: inherit;
text-decoration: initial;
text-decoration: unset;
默认值: none
继承: no
版本: CSS1
JavaScript 语法: object.style.textDecoration=”overline”

属性值

描述
none 默认。定义标准的文本。
underline 定义文本下的一条线。
overline 定义文本上的一条线。
line-through 定义穿过文本下的一条线。
blink 定义闪烁的文本。
inherit 规定应该从父元素继承 text-decoration 属性的值。

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

属性 谷歌浏览器 IE 浏览器 火狐浏览器 Safari 浏览器 Opera 浏览器
text-decoration 1.0 3.0 1.0 1.0 3.5

实例 1

设置 h1,h2,h3 和 h4 元素文本装饰:

<style>
h1 {text-decoration:overline;}
h2 {text-decoration:line-through;}
h3 {text-decoration:underline;}
</style>

<body>
<h1>这是标题 1</h1>
<h2>这是标题 2</h2>
<h3>这是标题 3</h3>
</body>

效果如下:

text-decoration 属性用来设置或删除文本的装饰

实例 2

虚线与波浪线:

<style>
h1 {
  text-decoration: underline overline dotted red;
}

h2 {
  text-decoration: underline overline wavy blue;
}
</style>

<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>

<p><strong>注意:</strong>在  Edge/Internet 浏览器中没有效果。</p>
</body>

效果如下:

虚线与波浪线

相关文章

CSS 教程: CSS Text 文本属性

「点点赞赏,手留余香」

0

给作者打赏,鼓励TA抓紧创作!

微信微信 支付宝支付宝

还没有人赞赏,快来当第一个赞赏的人吧!

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
码云笔记 » CSS text-decoration 属性

发表回复