HTML DOM Style listStyle property
Definition and Usage
listStyle shorthand property to set or return a list of three independent properties.
With this property, you can set / return:
- list-style-type
- list-style-position
- list-style-image
grammar
Setting listStyle properties:
Object.style.listStyle="type position image"
Back listStyle properties:
Object.style.listStyle
Tip: The default value listStyle attribute is "disc outside none".
参数 | 描述 |
---|---|
type | 定义列表项标记的类型。 |
position | 对列表项标记进行定位。 |
image | 定义图像为列表项标记。 |
inherit | listStyle 属性的值从父元素继承。 |
Browser Support
All major browsers support listStyle property.
Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".
Examples
Examples
Change the style of the list:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("ul1").style.listStyle="decimal inside";
}
</script>
</head>
<body>
<ul id="ul1">
<li>Coffee</li>
<li>Tea</li>
<li>Water</li>
<li>Soda</li>
</ul>
<br>
<button type="button" onclick="displayResult()">修改列表style</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("ul1").style.listStyle="decimal inside";
}
</script>
</head>
<body>
<ul id="ul1">
<li>Coffee</li>
<li>Tea</li>
<li>Water</li>
<li>Soda</li>
</ul>
<br>
<button type="button" onclick="displayResult()">修改列表style</button>
</body>
</html>
try it"
Style Objects