在 CSS 中格式化无序列表和有序列表
cssweb developmentfront end technology更新于 2025/2/6 5:32:17
无序列表和有序列表的样式和位置可以通过 CSS 属性 list-style-type、list-style-image 和 list-style-position 进行格式化。
语法
CSS list-style 属性的语法如下 −
Selector {
list-style: /*value*/
}
示例
以下示例说明了 CSS 列表样式属性 −
以下示例样式有序列表 −
<!DOCTYPE html>
<html>
<head>
<style>
ol {
list-style: upper-roman;
line-height: 150%;
}
</style>
</head>
<body>
<h2>Latest C# Versions</h2>
<ol>
<li>C# 8.0</li>
<li>C# 7.3</li>
<li>C# 7.2</li>
<li>C# 7.1</li>
<li>C# 7.0</li>
</ol>
</body>
</html>
输出
这将给出以下输出 −

示例
The following example styles unordered list −
<!DOCTYPE html>
<html>
<head>
<style>
ul > ul{
list-style: circle inside;
}
li:last-child {
list-style-type: square;
}
</style>
</head>
<body>
<h2>Programming Languages</h2>
<ul>
<li>C++ programming language created by Bjarne Stroustrup as an extension of the C programming language.</li>
<li>Java programming language developed by James Gosling.</li>
<ul>
<li>Core Java</li>
<li>Advanced Java</li>
</ul>
<li>Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way.</li>
</ul>
</body>
</html>
输出
这将给出以下输出 −

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

