Skip to content
Related Articles

Related Articles

Improve Article
How to Create Jumping Text 3D Animation Effect using CSS ?
  • Last Updated : 09 Jul, 2020

In this article, you will learn to implement Jumping Texts animation effect using simple HTML and CSS. HTML is used to create the structure of the page and CSS is used to set the styling.

HTML Code: In this section, we will design the basic structure of the body.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
      "width=device-width, initial-scale=1.0">
    <title>Text Jumping effect</title>
    <link rel="stylesheet" href="style.css">
</head>
  
<body>
    <h1>
        <span>G</span>
        <span>e</span>
        <span>e</span>
        <span>k</span>
        <span>s</span>
        <span>f</span>
        <span>o</span>
        <span>r</span>
        <span>G</span>
        <span>e</span>
        <span>e</span>
        <span>k</span>
        <span>s</span>
    </h1>
</body>
  
</html>

CSS Code: In this section, we will use some CSS property to design the Jumping text.

The CSS text-shadow property applies to create shadow to the text. It accepts a list of shadows separated by comma. The list will be applied to the text for its decorations. Some combination of X and Y offsets from the element describes each of the shadow. We are using @keyframes for the animation code. The animation is created by gradually changing from one set of CSS to another one. The change of all styles happen in percentage or the style change happens by using the keywords “from” and “to”, which is the same as 0% and 100%. The set of CSS can be changed many times.



CSS code:




<style>
    html, body {
        width: 100%;
        height: 100%;
        background: black;
        -webkit-font-smoothing: antialiased;
        display: flex;
        justify-content: center;
        align-items: center;
    }
  
    h1 {
        height: 100px;
    }
  
    h1 span {
        position: relative;
        top: 20px;
        display: inline-block;
        animation: bounce .3s ease infinite alternate;
        font-family: 'Titan One'cursive;
        font-size: 80px;
        color: #fff;
        text-shadow: 0 1px 0 green,
            0 2px 0 green,
            0 3px 0 green,
            0 4px 0 green,
            0 5px 0 green,
            0 6px 0 transparent,
            0 7px 0 transparent,
            0 8px 0 transparent,
            0 9px 0 transparent,
            0 10px 10px rgba(0, 0, 0, 0.4);
    }
  
    h1 span:nth-child(2) {
        animation-delay: .1s;
    }
  
    h1 span:nth-child(3) {
        animation-delay: .2s;
    }
  
    h1 span:nth-child(4) {
        animation-delay: .3s;
    }
  
    h1 span:nth-child(5) {
        animation-delay: .4s;
    }
  
    h1 span:nth-child(6) {
        animation-delay: .5s;
    }
  
    h1 span:nth-child(7) {
        animation-delay: .6s;
    }
  
    h1 span:nth-child(8) {
        animation-delay: .7s;
    }
  
    @keyframes bounce {
        100% {
            top: -20px;
            text-shadow: 0 1px 0 #CCC,
                0 2px 0 #CCC,
                0 3px 0 #CCC,
                0 4px 0 #CCC,
                0 5px 0 #CCC,
                0 6px 0 #CCC,
                0 7px 0 #CCC,
                0 8px 0 #CCC,
                0 9px 0 #CCC,
                0 50px 25px rgba(0, 0, 0, 0.2);
        }
    }
</style>

Complete Code: It is the combination of the above two code sections.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
  
    <title>Text Jumping effect</title>
  
    <style>
        html, body {
            width: 100%;
            height: 100%;
            background: black;
            -webkit-font-smoothing: antialiased;
            display: flex;
            justify-content: center;
            align-items: center;
        }
  
        h1 {
            height: 100px;
        }
  
        h1 span {
            position: relative;
            top: 20px;
            display: inline-block;
            animation: bounce .3s ease infinite alternate;
            font-family: 'Titan One'cursive;
            font-size: 80px;
            color: #fff;
            text-shadow: 0 1px 0 green,
                0 2px 0 green,
                0 3px 0 green,
                0 4px 0 green,
                0 5px 0 green,
                0 6px 0 transparent,
                0 7px 0 transparent,
                0 8px 0 transparent,
                0 9px 0 transparent,
                0 10px 10px rgba(0, 0, 0, 0.4);
        }
  
        h1 span:nth-child(2) {
            animation-delay: .1s;
        }
  
        h1 span:nth-child(3) {
            animation-delay: .2s;
        }
  
        h1 span:nth-child(4) {
            animation-delay: .3s;
        }
  
        h1 span:nth-child(5) {
            animation-delay: .4s;
        }
  
        h1 span:nth-child(6) {
            animation-delay: .5s;
        }
  
        h1 span:nth-child(7) {
            animation-delay: .6s;
        }
  
        h1 span:nth-child(8) {
            animation-delay: .7s;
        }
  
        @keyframes bounce {
            100% {
                top: -20px;
                text-shadow: 0 1px 0 #CCC,
                    0 2px 0 #CCC,
                    0 3px 0 #CCC,
                    0 4px 0 #CCC,
                    0 5px 0 #CCC,
                    0 6px 0 #CCC,
                    0 7px 0 #CCC,
                    0 8px 0 #CCC,
                    0 9px 0 #CCC,
                    0 50px 25px rgba(0, 0, 0, 0.2);
            }
        }
    </style>
</head>
  
<body>
    <h1>
        <span>G</span>
        <span>e</span>
        <span>e</span>
        <span>k</span>
        <span>s</span>
        <span>f</span>
        <span>o</span>
        <span>r</span>
        <span>G</span>
        <span>e</span>
        <span>e</span>
        <span>k</span>
        <span>s</span>
    </h1>
</body>
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :