如何使用JavaScript设置文本第一行的缩进?
要设置缩进,请使用textIndent 属性。
示例
您可以尝试运行以下代码以使用JavaScript返回文本第一行的缩进-
<!DOCTYPE html>
<html>
<body>
<div id = "myText">
This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
</div>
<br>
<button onclick = "display()">Set Text Indent</button>
<script>
function display() {
document.getElementById("myText").style.textIndent = "50px";
}
</script>
</body>
</html>热门推荐
4 会仙桥祝福语简短
10 弟弟致辞简短婚礼祝福语
11 公司开业纪念祝福语简短
12 虎年五一祝福语大全简短
13 朋友参军的简短祝福语
14 关于长辈祝福语大全简短
15 哥哥生孩子祝福语简短
16 粤语妈妈婚礼祝福语简短
17 即将毕业文案祝福语简短
18 送给老街的祝福语简短