/jumping-text

Primary LanguageCSSMIT LicenseMIT

Hey! Today I created bouncing text in pure HTML and CSS.

All animation is based on @keyframes.

Demonstration: codepen

Download: github

HTML code

<div id="wrapper">
    <div id="container">
        <h1>Simple Text</h1>
    </div>
</div>

CSS code

*, :before, :after {
    box-sizing: border-box;
}
body {
    background-color: #fff;
    font: 16px/1.25 'Titan one', sans-serif;
    text-align: center;
}
#wrapper {
    margin: 0 auto;
}
#container {
    display: flex;
    flex-direction: column;
    float: left;
    justify-content: center;
    min-height: 100vh;
    padding: 1em;
    width: 100%;
}
h1 {
    animation: text-shadow 2s ease-in-out infinite;
    font-size: 5em;
    font-weight: 900;
    line-height: 1;
    color: #ec4f43;
}
@keyframes text-shadow {
    0% {
        transform: translateY(0);
        text-shadow:
            0 0 0 #fe7968,
            0 0 0 #fe948d,
            0 0 0 #ffbdb3,
            0 0 0 #ffe0db;
    }
    20% {
        transform: translateY(-0.2em);
        text-shadow:
            0 0.125em 0 #fe7968,
            0 0.25em 0 #fe948d,
            0 -0.125em 0 #ffbdb3,
            0 -0.25em 0 #ffe0db;
    }
    40% {
        transform: translateY(0.1em);
        text-shadow:
            0 -0.0625em 0 #fe7968,
            0 -0.125em 0 #fe948d,
            0 0.0625em 0 #ffbdb3,
            0 0.125em 0 #ffe0db;
    }
    60% {
        transform: translateY(-0.1em);
        text-shadow:
            0 0.03125em 0 #fe7968,
            0 0.0625em 0 #fe948d,
            0 -0.03125em 0 #ffbdb3,
            0 -0.0625em 0 #ffe0db;
    }
    80% {
        transform: translateY(0);
        text-shadow:
            0 0 0 #fe7968,
            0 0 0 #fe948d,
            0 0 0 #ffbdb3,
            0 0 0 #ffe0db;
    }
}