css选择器
- 通用选择器
- 类选择器
- id选择器
- 元素选择器
- 属性选择器
- 兄弟选择器
- 后代选择器
- 交集选择器
- 并集选择器
- 伪类选择器
- 伪元素选择器
属性选择器
兄弟选择器
相邻兄弟用+
全部兄弟用~
<!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>
/* 相邻用+ */
.box1+div{
color: red;
}
/* 普遍用~ */
.box1~div{
font-size: 98px;
}
</style>
</head>
<body>
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</body>
</html>
后代选择器
交集选择器、并集选择器
伪类选择器
常见伪类: