Transition the background color of the page every 500ms using minimal css and javascript.
A Pen by Chris Mytton on CodePen.
Transition the background color of the page every 500ms using minimal css and javascript.
A Pen by Chris Mytton on CodePen.
window.onload = function() { | |
setInterval(function() { | |
document.body.style.cssText = "background-color: rgb(" + [Math.floor(Math.random() * 255), Math.floor(Math.random() * 255), Math.floor(Math.random() * 255)].join(",") + ")"; | |
}, 500); | |
}; |
body { | |
transition: background-color 500ms linear; | |
} |