一直想不通的一个小问题,因为刚开始学,很多东西不理解

就是结构伪类选择器怎样选择列表并为其加上背景图

题主的html结构什么样的,这个需要结合HTML结构

img


https://blog.csdn.net/ixygj197875/article/details/79038041

伪类选择器上背景图我没有合适的就给你上颜色了
效果图

img

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li:nth-child(1){
            background-color: red;
        }
    </style>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>
</body>
</html>