Add different cycling texts that fade in. Gives a nice touch to the landing page.
A Pen by Rajeev Singh Naruka on CodePen.
Add different cycling texts that fade in. Gives a nice touch to the landing page.
A Pen by Rajeev Singh Naruka on CodePen.
<body> | |
<h1 class="main-text"> | |
</h1> | |
</body> |
const text = document.querySelector(".main-text"); | |
var n = 0; | |
let timer = setInterval(onTick, 2500); | |
function onTick() { | |
if (n === 0) { | |
text.innerHTML = " Hi there! I'm <span >Rajeev</span>"; | |
n = 1; | |
return; | |
} | |
if (n === 4) { | |
text.innerHTML = ' Hi there! I\'m <span class="jobs" ">Rajeev</span>'; | |
n = 1; | |
return; | |
} else if (n == 1) { | |
text.innerHTML = ' Hi there! I\'m <span class="jobs">a Developer</span>'; | |
n = 2; | |
return; | |
} else if (n == 2) { | |
text.innerHTML = | |
' Hi there! I\'m <span class="jobs">a Motion Artist</span>'; | |
n = 3; | |
return; | |
} else if (n == 3) { | |
text.innerHTML = ' Hi there! I\'m <span class="jobs">a Game Dev</span>'; | |
n = 4; | |
return; | |
} | |
} |
@import url("https://fonts.googleapis.com/css?family=Roboto&display=swap"); | |
body{ | |
background: black; | |
} | |
.main-text { | |
color: white; | |
font-size: 4rem; | |
font-family: Roboto, sans-serif; | |
text-align: left; | |
margin-left: 25%; | |
margin-right: 10%; | |
animation: fadein 4s; | |
animation-timing-function: ease-in; | |
-moz-animation: fadein 4s; /* Firefox */ | |
-webkit-animation: fadein 4s; /* Safari and Chrome */ | |
-o-animation: fadein 4s; /* Opera */ | |
} | |
.jobs { | |
color: white; | |
font-size: 4rem; | |
font-family: Roboto, sans-serif; | |
text-align: left; | |
animation: fadein 4s; | |
animation-timing-function: ease-in; | |
-moz-animation: fadein 4s; /* Firefox */ | |
-webkit-animation: fadein 4s; /* Safari and Chrome */ | |
-o-animation: fadein 4s; /* Opera */ | |
} | |
@keyframes fadein { | |
from { | |
opacity: 0; | |
} | |
to { | |
opacity: 1; | |
} | |
} | |
@-moz-keyframes fadein { | |
/* Firefox */ | |
from { | |
opacity: 0; | |
} | |
to { | |
opacity: 1; | |
} | |
} | |
@-webkit-keyframes fadein { | |
/* Safari and Chrome */ | |
from { | |
opacity: 0; | |
} | |
to { | |
opacity: 1; | |
} | |
} | |
@-o-keyframes fadein { | |
/* Opera */ | |
from { | |
opacity: 0; | |
} | |
to { | |
opacity: 1; | |
} | |
} |
gist from my portfolio's landing page.