<!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>
ul {
width: 200px;
height: 300px;
list-style: none;
padding: 0;
margin: 0;
margin: 0 auto;
}
ul li {
height: 60px;
line-height: 60px;
text-align: center;
}
/* .demo {
background-color: #f00;
} */
/* li:nth-child(5) {
background-color: #f00;
} */
/* nth-child() 结构性选择器,选择同名同级别第几个元素 */
li:nth-child(2n){
background-color: #f00;
}
/* 进阶版,通过设置()内的数值,进行操作,其中:2n+1表示奇数行,2n表示偶数行 */
</style>
</head>
<body>
<ul>
<li>1</li>
<li class="demo">2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</body>
</html>