質問編集履歴
1
内容をアップデートしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
+
z-indexの並び順について
|
2
|
+
|
3
|
+
理想の並び順は上の階層から
|
4
|
+
|
1
|
-
.circle
|
5
|
+
.square .square:before .circle .circle:before
|
6
|
+
|
7
|
+
にしたいと思っています。
|
8
|
+
|
9
|
+
現状のコードでは.square:before が最下部に来てしまい、またdiv要素にz-indexをつけてしまうと擬似要素がdiv要素の上に来てしまいます。
|
10
|
+
|
11
|
+
理想の並び順にすることは可能でしょうか?
|
12
|
+
|
13
|
+
|
2
14
|
|
3
15
|
よろしくお願いいたします。
|
4
16
|
|
@@ -6,7 +18,11 @@
|
|
6
18
|
|
7
19
|
```HTML
|
8
20
|
|
21
|
+
<div class="circle">
|
22
|
+
|
9
|
-
<div class="
|
23
|
+
<div class="square"></div>
|
24
|
+
|
25
|
+
</div>
|
10
26
|
|
11
27
|
```
|
12
28
|
|
@@ -23,8 +39,6 @@
|
|
23
39
|
background: skyblue;
|
24
40
|
|
25
41
|
position: relative;
|
26
|
-
|
27
|
-
z-index: 1;
|
28
42
|
|
29
43
|
}
|
30
44
|
|
@@ -50,6 +64,36 @@
|
|
50
64
|
|
51
65
|
}
|
52
66
|
|
67
|
+
.square {
|
53
68
|
|
69
|
+
width: 20px;
|
70
|
+
|
71
|
+
height: 20px;
|
72
|
+
|
73
|
+
background: pink;
|
74
|
+
|
75
|
+
position: relative;
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
.square:before {
|
80
|
+
|
81
|
+
content: "";
|
82
|
+
|
83
|
+
width: 100%;
|
84
|
+
|
85
|
+
height: 100%;
|
86
|
+
|
87
|
+
background: navy;
|
88
|
+
|
89
|
+
z-index: -1;
|
90
|
+
|
91
|
+
position: absolute;
|
92
|
+
|
93
|
+
top: 5px;
|
94
|
+
|
95
|
+
left: 5px;
|
96
|
+
|
97
|
+
}
|
54
98
|
|
55
99
|
```
|