CSS中的小圆圈通常用于列表符号。我们可以通过list-style-type: circle;来设置列表项的符号为小圆圈。
ul {
list-style-type: circle;
} 如果想在其他元素中使用小圆圈,可以通过伪元素::before来实现。我们给元素添加一个content: "";并设置display: inline-block;来创建一个内容为空的块状元素。然后,通过设置border-radius: 50%;把这个块状元素变成圆形,在设置大小以及样式。
.circle {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
background-color: black;
margin-right: 5px;
}
/* 在伪元素::before中使用 */
.link::before {
content: "";
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
background-color: black;
margin-right: 5px;
} 以上代码中,我们首先定义了一个.circle类,用于创建小圆圈。然后,在伪元素::before中使用.circle类来实现,通过设置content: ""让伪元素呈现为空,只有通过::before的样式创建的小圆圈。