CSS 中的列表样式

cssweb developmentfront end technology更新于 2025/1/6 16:12:17

CSS 允许我们通过指定背景、列表样式属性、字体样式等来设置列表样式。列表样式属性是按相同顺序指定列表样式类型、列表样式图像和列表样式位置的简写形式。

语法

CSS 列表样式属性的语法如下 −

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

示例

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

<!DOCTYPE html>
<html>
<head>
<style>
ul {
   display: flex;
   float: left;
   list-style-image: url("https://www.cainiaomax.com/images/reactjs.png");
   background: lightseagreen;
   list-style-position: inside;
}
li {
   background: azure;
   margin: 5px 20px;
}
</style>
</head>
<body>
<h3>ReactJS</h3>
<ul>
<li>Lesson 1</li>
<li>Lesson 2</li>
<li>Lesson 3</li>
<li>Lesson 4</li>
<li>Lesson 5</li>
</ul>
</body>
</html>

输出

这将给出以下输出 −

示例

<!DOCTYPE html>
<html>
<head>
<style>
ol {
   width: 40%;
   color: white;
   list-style: lower-greek inside;
   background-image: url("https://www.cainiaomax.com/ethereum/images/ethereum-mini-logo.jpg");
}
li {
   background-color: rgba(0,0,0,0.6);
   margin: 5px 30px;
}
</style>
</head>
<body>
<h2>Ethereum</h2>
<ol>
<li>Smart Contracts</li>
<li>Ganache</li>
<li>Creating Wallet </li>
<li>Deploying Contract</li>
</ol>
</body>
</html>

输出

这将给出以下输出 −


相关文章


有用资源