HTML DOM textIndent 屬性
定義和用法
textIndent 屬性縮進(jìn)元素中的首行文本。
語(yǔ)法:
Object.style.textIndent=length|%
可能的值
值 | 描述 |
---|---|
length | 定義固定的縮進(jìn)。默認(rèn)值:0。 |
% | 定義基于父元素寬度的百分比的縮進(jìn)。 |
實(shí)例
本例縮進(jìn)文本:
<html>
<head>
<script type="text/javascript">
function setTextIndent()
{
document.getElementById("div1").style.textIndent="50px";
}
</script>
</head>
<body>
<div id="div1">
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</div>
<br />
<input type="button" onclick="setTextIndent()"
value="Indent first line of text" />
</body>
</html>