Typewriter animation that is created with JavaScript. This animation can be used for content that spans across multiple lines without any modification unlike many CSS animations out there.
A Pen by Billy Ferris on CodePen.
<body> | |
<p class="content"> | |
<span class="typewrite anim-typewrite js-typewrite"></span> | |
</p> | |
</body> |
var i = 0; | |
var txt = 'Typewriter animation style using JavaScript'; | |
function typeWriter() { | |
if (i < txt.length) { | |
document.getElementsByClassName('js-typewrite')[0].innerHTML += txt.charAt(i); | |
i++; | |
setTimeout(typeWriter, 65); | |
} | |
} | |
setTimeout(typeWriter, 1000); |
@import url(https://fonts.googleapis.com/css?family=Anonymous+Pro); | |
html { | |
min-height: 100%; | |
overflow: hidden; | |
} | |
body { | |
background-color: rgb(25,25,25); | |
color: rgba(255,255,255,.75); | |
font-family: 'Anonymous Pro', monospace; | |
height: calc(100vh - 8em); | |
padding: 4em; | |
} | |
.content { | |
display: block; | |
font-family: 'Anonymous Pro', sans-serif; | |
height: auto; | |
margin: auto; | |
position: relative; | |
text-align: center; | |
top: 40%; | |
width: -webkit-calc(70%); | |
} | |
.typewrite { | |
font-size: 180%; | |
border-right: 2px solid rgba(255,255,255,.75); | |
line-height: 1.15; | |
} | |
.anim-typewrite { | |
animation: blinkTextCursor 500ms infinite normal; | |
} | |
@keyframes blinkTextCursor{ | |
from{border-right-color: rgba(255,255,255,.75);} | |
to{border-right-color: transparent;} | |
} | |
/* style inspired by Thiago Teles Pereira @thiagoteles */ |
Typewriter animation that is created with JavaScript. This animation can be used for content that spans across multiple lines without any modification unlike many CSS animations out there.
A Pen by Billy Ferris on CodePen.