+ 4

Change background-color

How can I change the background color of a div every 7 seconds?

24th Mar 2019, 10:48 AM
Nerderkips
Nerderkips - avatar
5 Answers
+ 12
U can also use css animation and adjust the timing accordingly. A example not fully based on ur question but it can give u an idea : https://code.sololearn.com/WrZJZI6mOPyv/?ref=app
24th Mar 2019, 11:13 AM
Arushi Singhania
Arushi Singhania - avatar
+ 10
So, the idea is, create random color every given milliseconds
24th Mar 2019, 11:06 AM
Jingga Sona
Jingga Sona - avatar
+ 9
Do you want to do it with CSS Or Javascript?
24th Mar 2019, 10:56 AM
Jingga Sona
Jingga Sona - avatar
+ 9
My suggestion is using JS, i have a sample for you, if you want me to made a new code for this question, tell me https://code.sololearn.com/Wtg9mOU04RZi/?ref=app But if you want the easy way, i should recommend you CSS, but CSS Did not giving you random color, only color that have been set
24th Mar 2019, 11:02 AM
Jingga Sona
Jingga Sona - avatar
+ 6
I don't know. What is better?
24th Mar 2019, 10:58 AM
Nerderkips
Nerderkips - avatar