如何使用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>热门推荐
8 医政科祝福语简短
10 离别简短的祝福语大全
11 周末祝福语简短的英语
12 圣诞祝福语简短小学
13 直播生孩子祝福语简短
14 中秋祝福语送朋友简短
15 婚礼祝福语简短情话短句
16 别人过大寿祝福语简短
17 学生开学季祝福语简短
18 表达朋友的祝福语简短