在 CSS 中设置列​​表样式类型

cssweb developmentfront end technology更新于 2025/1/5 3:56:17

CSS 的 list-style-type 属性用于设置列表项标记的样式。我们可以将这些样式应用于无序列表和有序列表。

语法

CSS list-style-type 属性的语法如下 −

Selector {
   list-style-type: /*value*/
}

示例

以下示例说明了列表的样式

<!DOCTYPE html>
<html>
<head>
<style>
ol li {
   padding: 5px;
   list-style-type: lower-roman;
}
li:last-child {
   font-size: 1.2em;
   font-style: italic;
   list-style-type: circle;
}
</style>
</head>
<body>
<ol>
<li>demo1</li>
<li>
demo 2
<ul>
<li>demo a</li>
<li>demo b</li>
</ul>
</li>
<li>demo 3</li>
</ol>
</body>
</html>

输出

这将给出以下输出 −

示例

<!DOCTYPE html>
<html>
<head>
<style>
ol li {
   width: 50%;
   margin: 5px;
   font-size: 1.2em;
   list-style-type: devanagari;
   border: thin solid;
   background: linear-gradient(to right, lightgreen, pink,lightblue);
}
li:last-child {
   font-style: italic;
   list-style-type: lower-latin;
}
</style>
</head>
<body>
<ol>
<li>Eh!?</li>
<li>
demo one
<ol>
<li>What!?</li>
<li>demo two</li>
</ol>
</li>
<li>demo 3</li>
<li>demo four</li>
</ol>
</body>
</html>

输出

这将给出以下输出


相关文章


有用资源