JSFiddle - React, Tailwind, and code Playground
by Gene Lim
HTML
<div class="pie-container">
<pie class="ten">
<div class="mask"></div>
</pie>
<div class="consumption-label">--</div>
</div>
CSS
@-webkit-keyframes circle {
from { transform:rotate(0deg); }
to { transform:rotate(360deg); }
}
@-webkit-keyframes inner-circle {
from { transform:rotate(0deg); }
to { transform:rotate(-360deg); }
}
.pie-container {
width: 180px;
height: 180px;
}
pie {
width: 180px;
height: 180px;
display: block;
border-radius: 50%;
background-color: red;
margin: 1em;
-webkit-animation: circle 2s linear infinite;
}
.ten {
background-image:
linear-gradient(115deg, transparent 50%, white 50%),
linear-gradient(90deg, white 50%, transparent 50%);
transition: all 500ms;
}
.consumption-label {
font-weight: bold;
font-size: 40px;
position: absolute;
margin-left: 15%;
margin-top: 32%;
width: 130px;
text-align: center;
}
JavaScript
setInterval(function() {
var watt = Math.random() * 3
$('.ten').css('animation-duration', watt+'s');
}, 1000);