-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcss.py
230 lines (193 loc) · 5.67 KB
/
css.py
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
tree = """
/* Credits */
/* Ilya Pestov: Original, https://codepen.io/Pestov/pen/BLpgm */
/* Paul Smirnov: Horizontal, https://codepen.io/paulsmirnov/pen/dyyOLwa */
/* Background pattern, https://projects.verou.me/css3patterns/ */
/* Shane Drabing: Changed styling, added image hover effects */
/* Variables */
:root {
--border-radius: 3px;
--border-width: 2px;
--border-padding: 10px;
--transition-speed: 0.5s;
--bg-color1: hsl(210, 10%, 50%);
--bg-color2: hsl(210, 10%, 52%);
--box-color: hsl(0, 0%, 75%);
--border-color: hsl(0, 0%, 75%);
--text-color: hsl(0, 0%, 25%);
--box-color-hover: hsl(0, 0%, 100%);
--border-color-hover: hsl(0, 0%, 100%);
--text-color-hover: hsl(0, 0%, 0%);
}
/* Now the CSS */
* {
margin: 0;
padding: 0;
}
body {
background:
radial-gradient(circle at 40px 20px, transparent 10px, var(--bg-color1) 10px, var(--bg-color1), 20px, transparent 20px, transparent) 0px 0px,
radial-gradient(circle at 0px 20px, transparent 10px, var(--bg-color1) 10px, var(--bg-color1), 20px, transparent 20px, transparent) 0px 30px;
background-color: var(--bg-color2);
background-size: 40px 60px;
}
.tree {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
padding-top: 50px;
padding-left: 25px;
padding-right: 25px;
padding-bottom: 250px;
}
.tree ul {
padding-left: var(--border-padding);
position: relative;
transition: all var(--transition-speed);
-webkit-transition: all var(--transition-speed);
-moz-transition: all var(--transition-speed);
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.tree li {
text-align: center;
list-style-type: none;
position: relative;
padding: var(--border-radius) 0 var(--border-radius) var(--border-padding);
display: -webkit-box;
display: -ms-flexbox;
display: flex;
transition: all var(--transition-speed);
-webkit-transition: all var(--transition-speed);
-moz-transition: all var(--transition-speed);
}
/* We will use ::before and ::after to draw the connectors */
.tree li::before, .tree li::after {
content: '';
position: absolute;
left: 0;
bottom: 50%;
border-left: var(--border-width) solid var(--border-color);
width: var(--border-padding);
height: 50%;
}
.tree li::after {
bottom: auto;
top: 50%;
border-top: var(--border-width) solid var(--border-color);
}
/* We need to remove left-right connectors from elements without
any siblings */
.tree li:only-child::after, .tree li:only-child::before {
display: none;
}
/* Remove space from the top of single children */
.tree li:only-child {
padding-left: 0;
}
/* Remove left connector from first child and
right connector from last child */
.tree li:first-child::before, .tree li:last-child::after {
border: 0 none;
}
/* Adding back the vertical connector to the last nodes */
.tree li:last-child::before {
border-bottom: var(--border-width) solid var(--border-color);
border-radius: 0 0 var(--border-radius) 0;
-webkit-border-radius: 0 0 var(--border-radius) 0;
-moz-border-radius: 0 0 var(--border-radius) 0;
}
.tree li:first-child::after {
border-radius: 0 0 0 var(--border-radius);
-webkit-border-radius: 0 0 0 var(--border-radius);
-moz-border-radius: 0 0 0 var(--border-radius);
}
/* Time to add downward connectors from parents */
.tree ul ul::before {
content: '';
position: absolute;
left: 0;
top: 50%;
border-top: var(--border-width) solid var(--border-color);
width: var(--border-padding);
height: 0;
}
/* Box styles */
.tree li div {
cursor: pointer;
border: var(--border-width) solid var(--border-color);
padding: 4px 8px;
text-decoration: none;
color: var(--text-color);
background-color: var(--box-color);
font-family: arial, verdana, tahoma;
font-size: 12px;
display: flex-end;
-ms-flex-item-align: center;
-ms-grid-row-align: center;
align-self: center;
border-radius: var(--border-radius);
-webkit-border-radius: var(--border-radius);
-moz-border-radius: var(--border-radius);
transition: all var(--transition-speed);
-webkit-transition: all var(--transition-speed);
-moz-transition: all var(--transition-speed);
}
/* Time for some hover effects */
/* We will apply the hover effect the the lineage of the element also */
.tree li div:hover, .tree li div:hover+ul li div {
background: var(--box-color-hover);
color: var(--text-color-hover);
border: var(--border-width) solid var(--border-color-hover);
}
/* Connector styles on hover */
.tree li div:hover+ul li::after, .tree li div:hover+ul li::before, .tree li div:hover+ul::before, .tree li div:hover+ul ul::before {
border-color: var(--border-color-hover);
}
/* Image hover effects */
a {
color: inherit;
text-decoration: none;
}
""".lstrip()
dynamic = """
img {
transition: all 0.75s;
-webkit-transition: all 0.75s;
-moz-transition: all 0.75s;
transition-timing-function: ease-out;
transition-delay: 75ms;
width: auto;
height: auto;
max-width: 0px;
max-height: 0px;
display: block;
visibility: hidden;
}
div.parent:hover img {
transition: all 0.5s;
transition-delay: 15ms;
max-width: 75vw;
max-height: 50vh;
visibility: visible;
}
""".rstrip()
block = """
img {
display: none;
}
div.parent:hover img {
display: block;
}
""".rstrip()