How to create a multiple line typing animation with only CSS?

30 views Asked by At

I'm trying to create a multiple line typing animation for my portfolio, introducing myself. it's for a college project, where I can only use html or css. No scripts. as an example, I am using the JetBrains Mono website, which has this animation in multiple lines.

JetBrains Mono website

i already make a typing animation, i used css animation and @keyframes

2

There are 2 answers

1
Kamalesh D On

.line {
  overflow: hidden;
  white-space: nowrap;
  animation: typing 2s steps(40, end) 1s forwards;
}

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

.typing-container {
  font-family: Arial, sans-serif;
  font-size: 24px;
  line-height: 1.5;
  padding: 20px;
}
<div class="typing-container">
  <p class="line">Hello.</p>
  <p class="line">I'm a devops engineer.</p>
</div>

2
Tanishq S On

This might help you achieve your desired output of "Multiline Typing Animation"

body {
  background: #1a1b1e;
  color: white;
  font-weight: 900;
  font-family: monospace;
  font-size: 2rem;
}

#typing-container {
  display: flex;
  flex-direction: column;
}

.typing-text {
  overflow: hidden;
  white-space: nowrap;
  width: 0;
  animation: typing 2s steps(28, end) forwards;
}


.typing-text:nth-child(1) {
  animation-delay: 0s;
}

.typing-text:nth-child(2) {
  animation-delay: 0.8s;
}

.typing-text:nth-child(3) {
  animation-delay: 1.2s;
}

.typing-text:nth-child(4) {
  animation-delay: 2s;
}

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}
<div id="typing-container">
  <span class="typing-text">JetBrains</span>
  <span class="typing-text">Mono.</span>
  <span class="typing-text">A typeface</span>
  <span class="typing-text">for developers.</span>
</div>