-
Notifications
You must be signed in to change notification settings - Fork 0
/
36进阶选择器.html
67 lines (60 loc) · 1.4 KB
/
36进阶选择器.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!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>
* {
margin: 0;
padding: 0;
}
/* 并集选择器 */
p , div {
color: #000;
}
/* 后代选择器 */
.father div {
width: 400px;
height: 100px;
background-color: #2b99ff;
}
/* 子代选择器 */
.son > div {
color: #ff0000;
}
/* 邻接兄弟选择器 */
.grandson2 + p {
color: pink;
}
/* 通用兄弟选择器 */
.grandson1 ~ p {
color: pink;
}
/* 关系选择器 */
.father > div[class="son-two"] {
background-color: #00f089;
}
</style>
</head>
<body>
<div class="father">
<div class="son">
<div>
children one
<div>description: first children</div>
</div>
</div>
<div class="son-two">
<p class="grandson1">children 1</p>
<p>children two</p>
<p>children two</p>
</div>
<div>
<p>children three</p>
<p class="grandson2">children 2</p>
<p>children five</p>
</div>
</div>
</body>
</html>