CSS text-decoration-line 属性
在段落的顶部显示一条线:
<!DOCTYPE html>
<html>
<head>
<style>
p {
text-decoration-line: overline;
-moz-text-decoration-line: overline;
/* 针对 Firefox 的代码 */
}
</style>
</head>
<body>
<p>
本实例中的段落上方会显示一条线。</p>
<p><b>注意:</b>几乎所有的主流浏览器都不支持 text-decoration-line 属性。</p>
<p><b>注意:</b>Firefox 支持另一个可替代该属性的属性,即 -moz-text-decoration-line 属性。</p>
</body>
</html>
浏览器支持
几乎所有的主流浏览器都不支持 text-decoration-line 属性。
Firefox 支持另一个可替代该属性的属性,即 -moz-text-decoration-line 属性。
定义和用法
text-decoration-line 属性规定文本修饰要使用的线条类型。
注意:您也可以使用 text-decoration 属性设置 text-decoration-line。text-decoration 属性是 text-decoration-line、text-decoration-style 和 text-decoration-color 属性的速记属性。
注意:您也可以同时使用多个值,比如 underline 和 overline,来在文本的上方和下方都显示线条。
<!DOCTYPE html>
<html>
<head>
<style>
p#myP {
text-decoration: underline;
}
</style>
</head>
<body>
<p id="myP">
Hello world!
</p>
<p>点击“尝试一下”按钮,改变段落的 text-decoration-line。</p>
<button onclick="myFunction()">尝试一下</button>
<script>
function myFunction() {
document.getElementById("myP").style.textDecorationLine = "overline";
document.getElementById("myP").style.MozTextDecorationLine = "overline"; // 针对 Firefox 的代码
}
</script>
<p><b>注意:</b>几乎所有的主流浏览器都不支持 textDecorationLine 属性。</p>
<p><b>注意:</b>Firefox 支持另一个可替代该属性的属性,即 MozTextDecorationLine 属性。</p>
</body>
</html>
默认值: | none |
---|---|
继承: | 否 |
可动画化: | 否。请参阅 可动画化(animatable)。 |
版本: | CSS3 |
JavaScript 语法: | object.style.textDecorationLine="overline" - 尝试一下 - |
CSS 语法
text-decoration-line: none|underline|overline|line-through|initial|inherit;
属性值
值 | 描述 | 测试 |
---|---|---|
none | 默认值。规定文本修饰没有线条。 | 测试 » |
underline | 规定文本的下方将显示一条线。 | 测试 » |
overline | 规定文本的上方将显示一条线。 | 测试 » |
line-through | 规定文本的中间将显示一条线。 | 测试 » |
initial | 设置该属性为它的默认值。请参阅 initial。 | 测试 » |
inherit | 从父元素继承该属性。请参阅 inherit。 |