JSFiddle - React, Tailwind, and code Playground
by Keith Jeter
HTML
<div class="col-xs-12 bc_samp_wrap">
<div class="bc_full_ring_wrap">
<div class="bc_ring_container">
<div class="circle bc_rad blue">
<span id="value" class="nu_numb">5</span>
<span class="sub_numb">MI</span>
</div>
</div>
</div>
<div>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
CSS
body {
font-family: 'Roboto', sans-serif;
}
.bc_samp_wrap {
display: flex;
background: #ffffff;
flex-direction: row;
justify-content: flex-start;
border: solid 1px #ddd;
padding: 15px;
margin-bottom: 15px;
-webkit-box-shadow: 0 1px 1px rgb(0 0 0 / 5%);
box-shadow: 0 1px 1px rgb(0 0 0 / 5%);
padding-top: 15px;
padding-bottom: 15px;
padding-left: -15px;
padding-right: -15px;
}
.bc_ring_container {
position: relative;
display: flex;
align-items: center;
overflow: hidden;
width: 80px;
height: 80px;
}
.nu_numb {
color: #fff;
position: absolute;
top: 42%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 18px;
font-weight: bold;
}
.sub_numb {
color: #fff;
font-size: 9px;
font-weight: bold;
margin-top: 30px;
display: block;
text-align: center;
}
/*-- nu pulse --*/
.bc_rad {
background: black;
border-radius: 50%;
box-shadow: 0 0 0 0 rgba(0, 0, 0, 1);
margin: 10px;
height: 50px;
width: 50px;
transform: scale(1);
animation: pulse-black 2s infinite;
}
.bc_rad.blue {
background: rgba(6, 76, 123, 1);
box-shadow: 0 0 0 0 rgba(52, 172, 224, 1);
animation: pulse-blue 2s infinite;
}
@keyframes pulse-blue {
0% {
transform: scale(0.95);
box-shadow: 0 0 0 0 rgba(52, 172, 224, 0.7);
}
70% {
transform: scale(1);
box-shadow: 0 0 0 10px rgba(52, 172, 224, 0);
}
100% {
transform: scale(0.95);
box-shadow: 0 0 0 0 rgba(52, 172, 224, 0);
}
}
/*-- nu pulse --*/
JavaScript
function animateValue(obj, start, end, duration) {
let startTimestamp = null;
const step = (timestamp) => {
if (!startTimestamp) startTimestamp = timestamp;
const progress = Math.min((timestamp - startTimestamp) / duration, 1);
obj.innerHTML = Math.floor(progress * (start - end) + end);
if (progress < 1) {
window.requestAnimationFrame(step);
}
};
window.requestAnimationFrame(step);
}
const obj = document.getElementById("value");
animateValue(obj, 100, 0, 10000);