<div role="progressbar" aria-valuenow="67" aria-valuemin="0" aria-valuemax="100" style="--value: 67"></div>
<a id="youtube" href="https://www.youtube.com/watch?v=aXmNG2wie7I" target="_blank">
<span>See how this demo was coded</span>
</a>
@keyframes progress {
0% { --percentage: 0; }
100% { --percentage: var(--value); }
}
@property --percentage {
syntax: '<number>';
inherits: true;
initial-value: 0;
}
[role="progressbar"] {
--percentage: var(--value);
--primary: #369;
--secondary: #adf;
--size: 300px;
animation: progress 2s 0.5s forwards;
width: var(--size);
aspect-ratio: 1;
border-radius: 50%;
position: relative;
overflow: hidden;
display: grid;
place-items: center;
}
[role="progressbar"]::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: conic-gradient(var(--primary) calc(var(--percentage) * 1%), var(--secondary) 0);
mask: radial-gradient(white 55%, transparent 0);
mask-mode: alpha;
-webkit-mask: radial-gradient(#0000 55%, #000 0);
-webkit-mask-mode: alpha;
}
[role="progressbar"]::after {
counter-reset: percentage var(--value);
content: counter(percentage) '%';
font-family: Helvetica, Arial, sans-serif;
font-size: calc(var(--size) / 5);
color: var(--primary);
}
/* demo */
body {
margin: 0;
display: grid;
place-items: center;
height: 100vh;
background: #f0f8ff;
}
/***/
#youtube {
z-index: 2;
display: block;
width: 100px;
height: 70px;
position: absolute;
bottom: 20px;
right: 20px;
background: red;
border-radius: 50% / 11%;
transition: transform 0.5s;
}
#youtube:hover,
#youtube:focus {
transform: scale(1.1);
}
#youtube::before {
content: "";
display: block;
position: absolute;
top: 7.5%;
left: -6%;
width: 112%;
height: 85%;
background: red;
border-radius: 9% / 50%;
}
#youtube::after {
content: "";
display: block;
position: absolute;
top: 20px;
left: 40px;
width: 45px;
height: 30px;
border: 15px solid transparent;
box-sizing: border-box;
border-left: 30px solid white;
}
#youtube span {
font-size: 0;
position: absolute;
width: 0;
height: 0;
overflow: hidden;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.