Create animation effects using pure css

Creating animation nowadays is becoming a lot easier than ever. There are many readymade library available to create animation effect.

In this article, we will discuss about one of these library. Animate.css is simple one css file library which provides cross-browser animations for any web application. The animate.css useful in home pages, sliders for attention-guiding hints. Animate.css.


Install animate.css using npm command.

npm install animate.css --save

Or simply add the CDN file directly in <head> tag of HTML code.

    <link rel="stylesheet" href="" />


After you add the library, just add animate__animated class along with along with any animation name with prefix animate__ to elements which you want to add animation.


<h1 class="heading animate__animated animate__bounce">An animated element</h1>

You can change animation duration by adding animate__delay-3s class where 3s is 3 seconds time of animation.

You can also add the effect to specific class using @keyframes directly to any class. You don't need to add animate__ prefix while adding it to animation. You also need to add animation-duration with it.

.heading {
    animation: bounce;
    animation-duration: 2s;

You can use Javascript code to add sugar with Animate.css library. This will create effect whenever you want any event occurs.

const elem = document.querySelector('.header');
elem.classList.add('animate__animated', 'animate__bounce');

Full Example:

<!DOCTYPE html>
    <meta charset="utf-8">
    <link href="[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="" />
    <div class="text-center mt-5">
        <h1 class="header animate__animated">I am dancing!</h1>
        <button class="btn btn-primary">Animate</button>
    <script type="text/javascript">
        document.querySelector('.btn-primary').addEventListener('click', function() {
            const elem = document.querySelector('.header');
            setTimeout(function() {
                const elem = document.querySelector('.header');
            }, 1000);

This way you can add animation to make your web application more attractive. You can get all animation effect name at here. I hope you liked this article.