Skip to content

Instantly share code, notes, and snippets.

@arbaz52
Last active March 18, 2017 19:01
Show Gist options
  • Save arbaz52/5435d279d2ec051a247bf398fdc57fb3 to your computer and use it in GitHub Desktop.
Save arbaz52/5435d279d2ec051a247bf398fdc57fb3 to your computer and use it in GitHub Desktop.
Awesome Welcome Block for Website
<html>
<head>
<link rel='stylesheet' href='welcome.css'>
<script src='welcome.js'></script>
</head>
<body>
<div id='welcome'>
<ul>
<li>W</li>
<li>e</li>
<li>l</li>
<li>c</li>
<li>o</li>
<li>m</li>
<li>e</li>
</ul>
</div>
</body>
</html>
html, body {
margin:0;
}
#welcome ul {
margin:0;
padding:0;
list-style: none;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
#welcome ul li{
font-size:50px;
color:white;
float:left;
text-transform: uppercase;
font-weight: bold;
transition: all 0.3s ease-in-out;
}
#welcome {
font-family:Century Gothic;
height:300px;
background:url("../images/dark_forest-wallpaper-960x600.jpg");
position:relative;
}
window.onload = function(){
//this will happen after the window fully loads
//getting all the words in the welcome text
welcomeWords = document.getElementById("welcome").getElementsByTagName("li");
//placing them in random places
for(i=0;i<welcomeWords.length;i++) {
var x = -100+parseInt(Math.random()*300);
var y = -100+parseInt(Math.random()*200);
welcomeWords[i].style.transform = "translate("+x+"px,"+y+"px)";
}
//after 1 second all of them will go back to their places
setTimeout(goBack,1000);
function goBack(){
console.log("going b")
for(i=0;i<welcomeWords.length;i++) {
welcomeWords[i].style.transform = "translate(0,0)";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment