Learn the process of implementing typewriter animation across multiple strings with CSS

Looking to achieve a typewriter animation effect on multiple strings? While most developers use JavaScript for this, I managed to create it using CSS. However, I've only been successful with two strings so far. Whenever I attempt a third string, it ends up overlapping.

Check out the CodePen link

Here's the HTML code:

<h1>I am Kirill 
    <div id="stmt1">Acquisition strategist</div>
    <div id="stmt2">Campaign executioner</div>
    <div id="stmt3">Semi-technical marketing lead</div>
</h1>

CSS code for the animation:

#stmt2 {
    margin-top: -40px;
}
#stmt1 {
    width: 25em;
    white-space: nowrap;
    overflow: hidden;
    animation: frag1type 10s steps(50, end) 0s infinite;
}

@keyframes frag1type {
    from { width: 0; opacity: 1; }
    37% { width: 25em; opacity: 1; }
    49% { width: 0; opacity: 1; }
    100% { width: 0; opacity: 1; }
}

#stmt2 {
    opacity: 0;
    width: 25em;
    white-space: nowrap;
    overflow: hidden;
    animation: frag2type 10s steps(50, end) 5s infinite;
}

@keyframes frag2type {
    from { width: 0; opacity: 1; }
    37% { width: 25em; opacity: 1; }
    49% { width: 0; opacity: 1; }
    100% { width: 0; opacity: 1; }
}

#stmt3 {
    margin-top: -40px;
}
#stmt3 {
    opacity: 0;
    width: 25em;
    white-space: nowrap;
    overflow: hidden;
    animation: frag3type 10s steps(50, end) 7s infinite;
}

@keyframes frag3type {
    from { width: 0; opacity: 1; }
    37% { width: 25em; opacity: 1; }
    49% { width: 0; opacity: 1; }
    100% { width: 0; opacity: 1; }
}

Answer №1

adjust time duration to 15 seconds, increase width in animation by 10% and decrease it by 25%

animation: frag1type 15s steps(50, end) 0s infinite;
animation: frag2type 15s steps(50, end) 5s infinite;
animation: frag3type 15s steps(50, end) 10s infinite;

@keyframes frag1type{

        from { width: 0; opacity:1; }
        10%{width:25em;opacity:1; }
        25%{width:0;opacity:1; }
        100%{width:0;opacity:1; }
}
@keyframes frag2type{

        from { width: 0; opacity:1; }
        10%{width:25em;opacity:1; }
        25%{width:0;opacity:1; }
        100%{width:0;opacity:1; }
}
@keyframes frag3type{

        from { width: 0; opacity:1; }
        10%{width:25em;opacity:1; }
        25%{width:0;opacity:1; }
        100%{width:0;opacity:1; }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Icon overflowing due to Bootstrap 4 card title

I'm currently working on implementing an expand/collapse feature with a red close 'X' button in a Bootstrap 4 card. I've almost got it working, but when I try to place the red close icon outside the element that controls the expand/coll ...

Ways to align elements horizontally while preventing them from shifting positions

I'm faced with a layout challenge where I need to place 2 components side by side, but I want one component to stay on the right without affecting the orientation of the other component. Example: https://i.stack.imgur.com/T5Ram.png Currently, when I ...

Enhance your web design skills by customizing Bootstrap5 framework styles using the @layer feature

Here is the HTML code I am working with: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name=& ...

Having trouble adjusting the space between the footer and the bottom of the page

Looking to create a footer using multiple elements The first element should be positioned at: left: 944px; top: 9749px; The second element should be positioned at: left: 715px; top: 9819px; The third element should be positioned at: left: 718px; top: ...

When using the `position: absolute` and `left: 50%` properties on content with a `width: fit-content`, the content gets wrapped in Windows,

Why does the below code behave differently on Windows and Mac? On Windows, the content wraps or the div occupies only 50% of the browser's width, causing the content to wrap if its width exceeds 50% of the browser's width. However, on Mac, it tri ...

What is the most creative way you can think of to create a CSS/JS animated

Is using an animated SVG the best way to create these wavy blobs for mobile compatibility? What approach would you take? Here is a similar example I found var wave = document.createElement("div"); wave.className += " wave"; docFrag.appendChil ...

Stepping up with Bootstrap and ReactJS

I'm currently working on developing a web application with ReactJS. I'm interested in understanding whether it's beneficial to combine React and Bootstrap, or if it's not worth the effort. Are there specific functionalities that can be ...

How to resolve the issue of a visible line between a clipped div and its parent div

When I zoom in, a faint, transparent line appears between the triangular div and its parent div. It seems like this issue is caused by anti-aliasing in the browser. Any suggestions on how I can fix this would be greatly appreciated. I've already attem ...

Utilizing a background image in the slick slider

<div id="largeCarousel" style="display:inline-block; float:right;"> <div class="homepage-item" style="padding-bottom:52%; position:relative; box-sizing:border-box;"> <div id="largeCarouselContent" style="position:absolute ...

The Bootstrap image column is not aligning in a straight line

For a project, I need to create inline images like the following: https://i.sstatic.net/J3oep.png This is my code snippet: <div class="col-lg-6"> <h2>Exchange</h2> </div> ... When I expected them to be displayed inline, the ...

Having trouble with HTML - JavaScript function not processing responseText?

On my website, there is a button array that displays the position of a robot by reading a text file using a php/ajax combo. The script initially sets all buttons to the same color and changes the color of the button to represent the robot's position. ...

Stack three DIVs vertically on the entire screen with a fixed page margin, ensuring no need for a scroll bar

I need help creating a layout with 3 DIVs stacked vertically, each taking up one third of the screen without causing a scroll-bar to appear. I also want an 8px margin around all three of them. Here's an image for reference... example image Ultimatel ...

Adjusting the left and right margins within a Bootstrap row nested inside a card component

I am struggling to adjust the left and right margins for a Bootstrap row inside a card. Below is my CSS code along with some screenshots for reference. <div class="container" style="margin-bottom: -20px;"> <div class=" ...

What is the best way to create separation between the href attribute of an a tag and the

Currently, I am utilizing Material UI in React and encountering an issue with the spacing between an <a tag and some text both before and after it. The lack of space is causing them to merge together. <Typography style={{ fontSize: 14, textAlig ...

The toggleClass() function appears to be functioning properly in all browsers except for IE11

Check out my code snippet: Using Jquery: $("#welcome-done").on("click", function(){ $(".welcome-box").toggleClass("hide"); }) In the CSS: .hide { display: none; } .welcome-box { padding-left: 0; background-color: white; border-radi ...

What are the benefits of using CSS to convert text to uppercase?

Today, I came across an intriguing observation. While browsing through code, I noticed that text was being transformed to uppercase using CSS instead of the common JavaScript method toUpperCase(). Surprisingly, this approach caused a test to fail. The test ...

Issue with hiding the overflow of the document's body

Despite finding a solution to a previous issue on Stack Overflow, I am now facing a new challenge. Adding margin:0em auto; to my page is causing it to have a 'jumpy' effect. .align-center-public { width:1000px; margin:0em auto; overf ...

Concealing excess background color in HTML/CSS

I'm currently experimenting with adding a background color shape, such as a large rotating div, to the background of my website. However, I've encountered an issue where placing this background in the desired location is causing a large margin to ...

Animate in Angular using transform without requiring absolute positioning after the animation is completed

Attempting to incorporate some fancy animations into my project, but running into layout issues when using position: absolute for the animation with transform. export function SlideLeft() { return trigger('slideLeft', [ state('void&a ...

``Is it possible to adjust the style of an HTML element based on the style of another element?

Within my web application, I am dynamically changing the style of an HTML element using JavaScript. Below is the code snippet: function layout() { if(document.getElementById('sh1').getAttribute('src') == "abc.png") { docum ...