Answer the question
In order to leave comments, you need to log in
How to make a circle in html + css, which, depending on the time, can be painted over using js?
So that for example 15 minutes look like this joxi.ru/GrqzYG1fQvBbGm, half an hour is half a filled circle and so on, intervals of 10 minutes.
Answer the question
In order to leave comments, you need to log in
I didn’t understand the question, but you can
A already intervals and a way to describe the change in colors, you need to describe it yourself
<div id="circle" style="width:100px; height:100px; border-radius:50px; background-color:RGB(255,0,0)"></div>
<script>
(function(){
var div=document.getElementById("circle");
var lastR=255;
var lastG=0;
var lastB =0;
setInterval(()=>{
div.style.backgroundColor="RGB("+lastR+","+lastG+","+lastB+")";
if(lastG<255)
lastG++;
else
lastG=0;
if(lastG<255){
lastB++;
}
else
lastB=0;
},100);
})();
</script>
The link from your question doesn't work. But if I understand correctly, why not use, for example, a gradient? If there are 2 colors, change the percentages in 2 places, and the degree of filling changes:
.circle {
width: 100px;
height: 100px;
border-radius: 50%;
background-image: linear-gradient(to top, red 0%, red 25%, black 25%, black 100%);
}
var progress = 10; // допустим, это прошедшие минуты, полученные из бд
var percent = Math.round(progress/60 * 100); // минуты в процентах от часа
var circle = document.getElementsByClassName('circle')[0]; // собственно, наш круг
circle.style.backgroundImage = "linear-gradient(to top, red 0%, red " + percent + "%, black " + percent + "%, black 100%)";
.circle {
border-radius: 50%;
border: 50px solid transparent;
border-right-color: black;
width: 0;
height: 0;
transform: rotate(-45deg);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question