Style textDecorationLine 属性

Style 对象参考手册 Style 对象

实例

在段落的顶部显示一条线:

document.getElementById("myP").style.textDecorationLine="overline";

尝试一下 »

定义和用法

textDecorationLine 属性设置或返回文本修饰要使用的线条类型。

注意:您也可以使用 textDecoration 属性设置 textDecorationLine。textDecoration 属性是 textDecorationLine、textDecorationStyle 和 textDecorationColor 属性的速记属性。

注意:您也可以同时使用多个值,比如 underline overline,来在文本的上方和下方都显示线条。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

几乎所有的主流浏览器都不支持 textDecorationLine 属性。

Firefox 支持另一个可替代该属性的属性,即 MozTextDecorationLine 属性。


语法

返回 textDecorationLine 属性:

object.style.textDecorationLine

设置 textDecorationLine 属性:

object.style.textDecorationLine="none|underline|overline|line-through|initial|inherit"

属性值

描述
none默认值。规定文本修饰没有线条。
underline规定文本的下方将显示一条线。
overline规定文本的上方将显示一条线。
line-through规定文本的中间将显示一条线。
initial设置该属性为它的默认值。请参阅 initial
inherit从父元素继承该属性。请参阅 inherit

技术细节

默认值:none
返回值:字符串,表示元素的 text-decoration-line 属性。
CSS 版本CSS3


相关文章

CSS 参考手册:text-decoration-line 属性


Style 对象参考手册 Style 对象

0 个评论

要回复文章请先登录注册