Skip to content

Instantly share code, notes, and snippets.

@pagelab
Created January 31, 2022 17:57
Show Gist options
  • Save pagelab/151683772125c374296aec6df18682af to your computer and use it in GitHub Desktop.
Save pagelab/151683772125c374296aec6df18682af to your computer and use it in GitHub Desktop.
Typewriter effect (CSS only)
<!DOCTYPE html>
<html>
<head>
<style>
.writer {
font-family: Courier, monospace;
display: inline-block;
}
.writer-text {
display: inline-block;
overflow: hidden;
letter-spacing: 2px;
animation: typing 5s steps(30, end), blink .75s step-end infinite;
white-space: nowrap;
font-size: 30px;
font-weight: 700;
border-right: 4px solid orange;
box-sizing: border-box;
}
@keyframes typing {
from {
width: 0%
}
to {
width: 100%
}
}
@keyframes blink {
from, to {
border-color: transparent
}
50% {
border-color: orange;
}
}
</style>
<body>
<div class="writer">
<div class="writer-text">Twinkle, twinkle, little star.</div>
</div>
</body>
</html>
@pagelab
Copy link
Author

pagelab commented Jan 31, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment