html text-indent,HTML Style textIndent用法及代码示例

DOM样式textIndent属性用于缩进每个文本块中的第一行。它还采用负值。如果该值为负,则第一行将向左缩进。

用法:

它用于设置textIndent属性:object.style.textIndent = "length|%|initial|inherit"

它用于获取textIndent属性:object.style.textIndent

属性:

length:它用于根据px,pt,cm,em等设置固定缩进。length的默认值为0。

百分比(%):与元素的宽度相比,它用于定义以%为单位的缩进。

initial:它用于将text-indent属性设置为其默认值。

返回值:它返回一个字符串值,该字符串值表示每个文本块中第一行的缩进。

例子:

DOM Style text-indent Property

#sudo {

text-indent:40px;

}

GeeksforGeeks

DOM Style text-indent Property

text-indent:40px:

Prepare for the Recruitment drive of product

based companies like Microsoft, Amazon, Adobe

etc with a free online placement preparation

course. The course focuses on various MCQ's

& Coding question likely to be asked in the

interviews & make your upcoming placement

season efficient and successful.

Submit

function myGeeks() {

document.getElementById("sudo").style.textIndent = "120px";

}

输出:

在单击按钮之前:

374f6c378e7d3c692e6a5b4ba54a56f8.png

单击按钮后:

a732b702658c539788dce8e255cb90bc.png

示例2:获取text-indent的值。

DOM Style text-indent Property

GeeksforGeeks

DOM Style text-indent Property

Prepare for the Recruitment drive of product

based companies like Microsoft, Amazon, Adobe

etc with a free online placement preparation

course. The course focuses on various MCQ's

& Coding question likely to be asked in the

interviews & make your upcoming placement

season efficient and successful.

Submit

function myGeeks() {

alert(document.getElementById("sudo").style.textIndent);

}

输出:

在单击按钮之前:

9a611574a229667b787ebde9cb293a1b.png

单击按钮后:

a9c551251cbd924598a9e83ee1470a92.png

支持的浏览器:下面列出了DOM Style textIndent支持的浏览器:

谷歌浏览器

IE浏览器

Firefox

Opera

Safari

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值