-
Notifications
You must be signed in to change notification settings - Fork 0
/
progress.html
336 lines (288 loc) · 10.3 KB
/
progress.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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<style>
@import url(https://fonts.googleapis.com/css?family=Expletus+Sans);
/* Basic resets */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 50px auto 0;
max-width: 800px;
font-family: 'Expletus Sans', sans-serif;
}
li {
width: 50%;
float: left;
list-style-type: none;
padding-right: 5.3333333%;
}
li:nth-child(even) {
margin-bottom: 5em;
}
h2 {
margin: 0 0 1.5em;
border-bottom: 1px solid #ccc;
padding: 0 0 0.25em;
}
/* Styling an indeterminate progress bar */
progress:not(value) {
/* Add your styles here. As part of this walkthrough we will focus only on determinate progress bars. */
}
/* Styling the determinate progress element */
progress[value] {
/* Get rid of the default appearance */
appearance: none;
/* This unfortunately leaves a trail of border behind in Firefox and Opera. We can remove that by setting the border to none. */
border: none;
/* Add dimensions */
width: 100%;
height: 20px;
/* Although firefox doesn't provide any additional pseudo class to style the progress element container, any style applied here works on the container. */
background-color: whiteSmoke;
border-radius: 3px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5) inset;
/* Of all IE, only IE10 supports progress element that too partially. It only allows to change the background-color of the progress value using the 'color' attribute. */
color: royalblue;
position: relative;
margin: 0 0 1.5em;
}
/*
Webkit browsers provide two pseudo classes that can be use to style HTML5 progress element.
-webkit-progress-bar -> To style the progress element container
-webkit-progress-value -> To style the progress element value.
*/
progress[value]::-webkit-progress-bar {
background-color: whiteSmoke;
border-radius: 3px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5) inset;
}
progress[value]::-webkit-progress-value {
position: relative;
background-size: 35px 20px, 100% 100%, 100% 100%;
border-radius: 3px;
/* Let's animate this */
animation: animate-stripes 5s linear infinite;
}
@keyframes animate-stripes {
100% {
background-position: -100px 0;
}
}
/* Let's spice up things little bit by using pseudo elements. */
progress[value]::-webkit-progress-value:after {
/* Only webkit/blink browsers understand pseudo elements on pseudo classes. A rare phenomenon! */
content: '';
position: absolute;
width: 5px;
height: 5px;
top: 7px;
right: 7px;
background-color: white;
border-radius: 100%;
}
/* Firefox provides a single pseudo class to style the progress element value and not for container. -moz-progress-bar */
progress[value]::-moz-progress-bar {
/* Gradient background with Stripes */
background-image: -moz-linear-gradient(
135deg,
transparent,
transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%
),
-moz-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2)),
-moz-linear-gradient(left, #09c, #f44);
background-size: 35px 20px, 100% 100%, 100% 100%;
border-radius: 3px;
/* Firefox doesn't support CSS3 keyframe animations on progress element. Hence, we did not include animate-stripes in this code block */
}
/* Fallback technique styles */
.progress-bar {
background-color: whiteSmoke;
border-radius: 3px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5) inset;
/* Dimensions should be similar to the parent progress element. */
width: 100%;
height: 20px;
}
.progress-bar span {
background-color: royalblue;
border-radius: 3px;
display: block;
text-indent: -9999px;
}
p[data-value] {
position: relative;
}
/* The percentage will automatically fall in place as soon as we make the width fluid. Now making widths fluid. */
p[data-value]:after {
content: attr(data-value) '%';
position: absolute;
right: 0;
}
.html5::-webkit-progress-value,
.python::-webkit-progress-value {
/* Gradient background with Stripes */
background-image: -webkit-linear-gradient(
135deg,
transparent,
transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%
),
-webkit-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2)),
-webkit-linear-gradient(left, #09c, #f44);
}
.css3::-webkit-progress-value,
.php::-webkit-progress-value {
/* Gradient background with Stripes */
background-image: -webkit-linear-gradient(
135deg,
transparent,
transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%
),
-webkit-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2)),
-webkit-linear-gradient(left, #09c, #ff0);
}
.jquery::-webkit-progress-value,
.node-js::-webkit-progress-value {
/* Gradient background with Stripes */
background-image: -webkit-linear-gradient(
135deg,
transparent,
transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%
),
-webkit-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2)),
-webkit-linear-gradient(left, #09c, #690);
}
/* Similarly, for Mozillaa. Unfortunately combining the styles for different browsers will break every other browser. Hence, we need a separate block. */
.html5::-moz-progress-bar,
.php::-moz-progress-bar {
/* Gradient background with Stripes */
background-image: -moz-linear-gradient(
135deg,
transparent,
transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%
),
-moz-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2)),
-moz-linear-gradient(left, #09c, #f44);
}
.css3::-moz-progress-bar,
.php::-moz-progress-bar {
/* Gradient background with Stripes */
background-image: -moz-linear-gradient(
135deg,
transparent,
transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%
),
-moz-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2)),
-moz-linear-gradient(left, #09c, #ff0);
}
.animated::-moz-progress-bar,
.node-js::-moz-progress-bar {
/* Gradient background with Stripes */
background-image: -moz-linear-gradient(
135deg,
transparent,
transparent 33%,
rgba(0, 0, 0, 0.1) 33%,
rgba(0, 0, 0, 0.1) 66%,
transparent 66%
),
-moz-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2)),
-moz-linear-gradient(left, #09c, #690);
}
/* Now we are good to duplicate html code for other skills and then add the css code for the new skill based on data-skill */
/* THE END */</style
>< !-- Lets start with a single html5 progress element. Currently our progress
bar is in the indeterminate state. Lets change the status by adding 'max'and
'value'attribute to our progress element. We are almost done styling a single
progress bar, except adding fallback technique for browsers that do not support
progress element. The idea is to simulate the visual styles of the progress bar
using `div` and `span`. Note:- To imitate the older browsers and help us style
the fallback technique, we wil temporarily comment-out the progress tag. -->
<ul>
<li>
<h2>Frontend</h2>
< !-- HTML5 -->
<p style="width:80%" data-value="80">HTML5</p>
<progress max="100" value="80" class="html5"
>< !-- Browsers that support HTML5 progress element will ignore the html
inside `progress` element. Whereas older browsers will ignore the
`progress` element and instead render the html inside it. -->
<div class="progress-bar">
<span style="width: 80%">80%</span>
</div></progress
>< !-- CSS3 -->
<p style="width:60%" data-value="60">CSS3</p>
<progress max="100" value="60" class="css3"
>< !-- Browsers that support HTML5 progress element will ignore the html
inside `progress` element. Whereas older browsers will ignore the
`progress` element and instead render the html inside it. -->
<div class="progress-bar">
<span style="width: 60%">60%</span>
</div></progress
>< !-- jQuery -->
<p style="width:50%" data-value="50">jQuery</p>
<progress max="100" value="50" class="jquery"
>< !-- Browsers that support HTML5 progress element will ignore the html
inside `progress` element. Whereas older browsers will ignore the
`progress` element and instead render the html inside it. -->
<div class="progress-bar">
<span style="width: 50%">50%</span>
</div></progress
>
</li>
<li>
<h2>Backend</h2>
< !-- Python -->
<p style="width:75%" data-value="75">Python</p>
<progress max="100" value="75" class="python"
>< !-- Browsers that support HTML5 progress element will ignore the html
inside `progress` element. Whereas older browsers will ignore the
`progress` element and instead render the html inside it. -->
<div class="progress-bar">
<span style="width: 75%">75%</span>
</div></progress
>< !-- PHP -->
<p style="width:65%" data-value="65">PHP</p>
<progress max="100" value="65" class="php"
>< !-- Browsers that support HTML5 progress element will ignore the html
inside `progress` element. Whereas older browsers will ignore the
`progress` element and instead render the html inside it. -->
<div class="progress-bar">
<span style="width: 65%">65%</span>
</div></progress
>< !-- Node.js -->
<p style="width:35%" data-value="35">Node.js</p>
<progress max="100" value="35" class="node-js"
>< !-- Browsers that support HTML5 progress element will ignore the html
inside `progress` element. Whereas older browsers will ignore the
`progress` element and instead render the html inside it. -->
<div class="progress-bar">
<span style="width: 35%">35%</span>
</div></progress
>
</li>
</ul>
<p>
Article -
<a href="https://css-tricks.com/html5-progress-element/"
>https: //css-tricks.com/html5-progress-element/</a
>
</p>