如何使用 CSS 更改列表的项目符号颜色?
cssweb developmentfront end technology更新于 2025/12/16 11:24:17
要使用 CSS 更改列表的项目符号颜色,代码如下 −
示例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
ul {
list-style: none;
}
ul li{
font-size: 20px;
font-weight: 500;
}
ul li::before {
content: "\2022";
color: rgb(86, 18, 117);
font-weight: bold;
display: inline-block;
width: 1em;
margin-left: -1em;
}
</style>
</head>
<body>
<h1>Change Bullet Color of List Example</h1>
<ul>
<li>Camel</li>
<li>Goat</li>
<li>Giraffe</li>
<li>Lion</li>
</ul>
</body>
</html>
输出
上述代码将产生以下输出 −

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

