A Pen by Ismael Paiva on CodePen.
Created
October 19, 2018 20:45
-
-
Save ippaiva/342502b8d1dc2b5405a7883f58c9e5ef to your computer and use it in GitHub Desktop.
GYGgaJ
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
<div id="color-overlay"><h1 id="text-bg">RAVE</h1></div> |
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
// Generates a random color in hexadecimal (ie. #62b9cc) | |
function generateRandomColor() { | |
return '#'+Math.floor(Math.random()*16777215).toString(16); | |
} | |
// Changes the color of the background using STYLE | |
function changeBackgroundColor() { | |
var colorBg = document.getElementById("color-overlay") | |
colorBg.style.backgroundColor = generateRandomColor(); | |
} | |
function changeBackgroundText() { | |
var textBg = document.getElementById("text-bg") | |
if (textBg.innerHTML == "RAVE") { | |
textBg.innerHTML = "OR" | |
} else if (textBg.innerHTML == "OR") { | |
textBg.innerHTML = "DIE" | |
} else if (textBg.innerHTML == "DIE") { | |
textBg.innerHTML = "RAVE" | |
}; | |
} | |
function changeBackground() { | |
changeBackgroundColor(); | |
changeBackgroundText(); | |
} | |
// Run this function every 300ms | |
setInterval(changeBackground, 300); |
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 { | |
padding: 0px; | |
margin: 0px; | |
background-image: url("https://static.pexels.com/photos/2143/lights-party-dancing-music.jpg"); | |
width: 100%; | |
height: 100vh; | |
background-size: cover; | |
} | |
#color-overlay { | |
width: 100%; | |
height: 100vh; | |
opacity: 0.8; | |
text-align: center; | |
color: #fff; | |
} | |
#text-bg { | |
line-height: 100vh; | |
font-size: 80px; | |
margin: 0px; | |
font-family: Verdana; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment