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
|
<html>
<body>
<input type=button data-position="0" value="Set 0%">
<br>
<input type=button data-position="25" value="Set 25%">
<br>
<input type=button data-position="50" value="Set 50%">
<br>
<input type=button data-position="75" value="Set 75%">
<br>
<input type=button data-position="100" value="Set 100%">
<br>
<div style="display: inline-block;">
<pre>Progress bar position: <span id="position-text"></span></pre>
</div>
<br>
<br>
<em>A system progress bar (appearance: auto)</em>
<br>
<br>
<progress value="25" max="100"></progress>
<br>
<br>
<em>A primitive progress bar (appearance: none)</em>
<br>
<br>
<progress style="appearance: none" value="25" max="100"></progress>
<br>
<br>
<em>A primitive progress bar (appearance: none) with some styling</em>
<br>
<br>
<progress id="custom-progress" value="25" max="100"></progress>
<br>
<br>
<em>A super fancy progress bar done purely in CSS</em>
<br>
<br>
<progress id="really-fancy-progress" value="25" max="100"></progress>
<br>
<style>
body {
background-color: #060606;
color: white;
margin-left: 20px;
}
#custom-progress {
appearance: none;
width: 200px;
height: 20px;
}
#custom-progress::-webkit-progress-bar {
border-radius: 10px;
overflow: hidden;
box-shadow: 0 0 10px 4px #ff3863d2;
background-color: #eee;
}
#custom-progress::-webkit-progress-value {
border-radius: 10px;
background-color: #ff3863d2;
}
/* The following example is taken from https://css-tricks.com/html5-progress-element/ */
#really-fancy-progress[value] {
appearance: none;
width: 500px;
height: 40px;
}
#really-fancy-progress[value]::-webkit-progress-bar {
background-color: #eee;
border-radius: 2px;
/* FIXME: Should be an inset shadow (not supported yet) */
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}
#really-fancy-progress[value]::-webkit-progress-value {
background-image:
-webkit-linear-gradient(-45deg,
transparent 33%, rgba(0, 0, 0, .1) 33%,
rgba(0,0, 0, .1) 66%, transparent 66%),
-webkit-linear-gradient(top,
rgba(255, 255, 255, .25),
rgba(0, 0, 0, .25)),
-webkit-linear-gradient(left, #09c, #f44);
border-radius: 2px;
background-size: 70px 40px, 100% 100%, 100% 100%;
}
</style>
<script>
const progressBars = document.querySelectorAll('progress');
const buttons = document.querySelectorAll('input[type=button]');
const positionText = document.getElementById('position-text');
const setProgressPositions = (position) => {
progressBars.forEach(progressBar => {
progressBar.value = position;
})
positionText.innerHTML = position;
}
buttons.forEach(button => {
button.onclick = event => {
const position = event.target.getAttribute("data-position") | 0;
setProgressPositions(position);
}
})
</script>
</body>
</html>
|