<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* 结构伪类选择器:因为依旧使用的是":",所以叫伪类,又因为和结构有关 */
ul li:first-child {
background-color: pink;
}
ul li:last-child {
background-color: skyblue;
}
/* nth-child(n)指定第几个元素 */
ul li:nth-child(8) {
background-color: deeppink;
}
</style>
</head>
<body>
<!-- ul>li{$}*10 -->
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
</body>
</html>
H5结构伪类选择器
最新推荐文章于 2023-05-14 15:02:35 发布