I have created a text typing animation, however, rather than the border stopping after the amount of characters is done, it continues on ahead, I tried setting the width to the no. of characters but this doesn't seem to help. How do I fix this problem?
.type h1{
animation: typing 3s steps(31);
overflow: hidden;
white-space: nowrap;
border-right: 2px solid black;
width: 31ch;
}
@keyframes typing {
0%{
width: 0ch;
}
100%{
width: 31ch;
}
}
<div class="type">
<h1>Hobbies, Goals, and Aspirations</h1>
</div>
ch
(ch is equal to width of all character only for monospace font otherwise it's the width of0
) – Temani Afif