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
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.
输出:
- 在点击按钮之前:
- 点击按钮后:
示例 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.
输出:
- 在点击按钮之前:
- 点击按钮后:
支持的浏览器: DOM Style textIndent支持的浏览器如下:
- 谷歌浏览器
- IE浏览器
- 火狐
- 歌剧
- 苹果浏览器