Believemy logo purple

Create a text rotation effect

To make your site more attractive, you could add this cool effect, which will display several words in succession with a looping deletion and rewriting effect. This effect can be placed at the end of a sentence, as in a text.
Updated on December 11, 2024
Believemy logo

To make your website more attractive, you can add this cool effect, which will display multiple words that will follow one another with a deletion and retyping effect in a loop. This effect can be placed at the end of a sentence like in a text.

 

Step 1

Let's start by inserting the libraries into the HTML code.

HTML
<head>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/2.0.11/typed.min.js"></script>
</head>

We will simply insert the libraries we need. In this case, jQuery and Typed.

The first (jQuery) will allow us to code our animation much more quickly, while the second (Typed) will enable us to create our animation with an effect that gives the impression that someone is typing and deleting the text.

 

Step 2

The HTML code.

HTML
<body>
  <div class="presentation">I am, <span class="texte"></span></div>
</body>

We will need the .texte class contained within the span tag to add the text we want to appear and then disappear in a loop automatically.

 

Step 3

Style the presentation class.

CSS
.presentation {
    font-weight: bold;
    font-size: 20px;
    }

 

Step 4

We will now handle the rotation.

JAVASCRIPT
$(document).ready(function(){
    var typed = new Typed(".texte", {
        strings: ["developer", "freelancer","blogger"],
        typeSpeed: 80,
        backSpeed: 60,
        loop: true
    });
});

In the previous step, we used jQuery to wait for the page to fully load before adding our animation.

Once our page is loaded, we use the Typed function, which allows us to define the strings of characters to display (strings).

For managing the typing, we will use typeSpeed and backSpeed for deletion. We then specify whether we want the animation to loop continuously or not using loop.

Congratulations! Your animation is ready!

Category: Development
Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Try for Free

Whether you're scaling your startup, building your first website, or transitioning to a developer role, Believemy is your new home. Join us, grow, and let’s build your project together.

Believemy is with anyone