HTML DOM Style listStyle 属性
htmlweb developmentfront end technology更新于 2024/3/16 23:40:17
HTML DOM Style listStyle 属性用于设置或返回 list-style-type、list-style-position 和 list-style-image 三个属性。
以下是语法 −
设置 listStyle 属性 −
object.style.listStyle = "type position image|initial|inherit"
以上属性解释如下 −
| 参数 | 描述 |
|---|---|
| type | 用于定义列表项标记类型。 |
| position | 用于设置列表项标记位置 |
| image | 用于指定设置为列表项标记的图像。 |
| initial | 将此属性设置为初始值。 |
| inherit | 继承父级属性值 |
让我们看一个 listStyle 属性的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<script>
function changeListStyle() {
document.getElementById("LIST1").style.listStyle = "upper-roman";
document.getElementById("Sample").innerHTML="The list style has been changed to upper Roman";
}
</script>
</head>
<body>
<ul id="LIST1">
<li>MANGO</li>
<li>GUAVA</li>
<li>LITCHI</li>
<li>WATERMELON</li>
</ul>
<p>Click the below button to change the list style for the above div</p>
<button type="button" onclick="changeListStyle()">Change list style</button>
<p id="Sample"></p>
</body>
</html>
输出

点击"更改列表样式"按钮 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

