[SOLVED] Is it possible to use CSS to change <div> elements background colour randomly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[SOLVED] Is it possible to use CSS to change <div> elements background colour randomly

I was just trying to practice CSS animation (code attached), where in I used CSS animation to rotate some <div> elements inside the page. I want the <div> elements to also change their background colour randomly, but I need help with changing background colour using CSS. As it is now, colour changes is done with JS function, and doesn't look so smooth (the colour transition). Here's the code bit ... https://code.sololearn.com/W578sR21C8T7/?ref=app Thanks in advance 🙏

27th Aug 2020, 8:05 AM
Ipang
2 Answers
+ 1
add CSS property in div selector transition-duration :2s; For smooth background color change
27th Aug 2020, 8:23 AM
Vadivelan
+ 1
Thank you Vadi velan Works like magic! 👍👍👍
27th Aug 2020, 8:35 AM
Ipang