-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path三个正方形.html
128 lines (112 loc) · 2.22 KB
/
三个正方形.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>正方形</title>
<style>
.box {
display: flex;
}
.box div {
margin: 10px;
}
.box1 {
position: relative;
background-color: red;
width: 20vw;
height: 20vw;
z-index: -3;
}
.box1:before {
content: "";
background-color: blue;
display: block;
width: 5vw;
height: 5vw;
z-index: -1;
}
.box1::after {
position: absolute;
top: 0;
left: 0;
content: "";
background-color: green;
display: block;
width: 10vw;
height: 10vw;
z-index: -2;
}
.box2 {
position: relative;
background-color: red;
width: 20vw;
height: 20vw;
z-index: -3;
}
.box2:before {
position: absolute;
content: "";
background-color: blue;
display: block;
width: 5vw;
height: 5vw;
z-index: -1;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.box2::after {
position: absolute;
top: 0;
left: 0;
content: "";
background-color: green;
display: block;
width: 10vw;
height: 10vw;
z-index: -2;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.box3 {
position: relative;
background-color: red;
width: 20vw;
height: 20vw;
z-index: -3;
}
.box3:before {
position: absolute;
content: "";
background-color: blue;
display: block;
width: 5vw;
height: 5vw;
z-index: -1;
right: 0;
bottom: 0;
}
.box3::after {
position: absolute;
content: "";
background-color: green;
display: block;
width: 10vw;
height: 10vw;
z-index: -2;
right: 0;
bottom: 0;
}
</style>
</head>
<body>
一、3个正方形盒子每个盒子各有1px外边距 颜色大小自定义,盒子尺寸跟随窗口大小变化实现效果如下
<div class="box">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</div>
</body>
</html>