Last active
December 29, 2017 18:57
-
-
Save ir3ne/dec91b31e9e723cd46d51419f48bcd5b to your computer and use it in GitHub Desktop.
JS Change body background color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const body = document.body; | |
const colors = ["#820263", "#D90368", "#86CB92", "#2E294E", "#FFD400", "#F46036"]; | |
let i = 0; | |
function change() { | |
body.style.backgroundColor = colors[i]; | |
i++; | |
if(i > colors.length - 1) { | |
i = 0; | |
} | |
} | |
setInterval(change, 3000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
transition: background-color 2s cubic-bezier(1, 1, 1, 1); | |
transition-delay: 0s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment