- Products -


Software


NEWS


Special



- Knowledge -


Category × Tag



- Like -

公開
作成日:2022/1/27
更新日:2022/3/4

cssで背景変化するアニメーションを実装する

・cssだけで背景アニメーションを実現することが可能。
・以下に例を示す。

実装例



・スタイル

body {
    background: linear-gradient(-45deg, #c2f9d0, #ffdea5, #f9c2eb, #a8c2ee) fixed;
    background-size: 800% 800%;
    animation: GradietionAnimation 32s ease infinite;
    margin: 0;
}

@keyframes GradietionAnimation {
    0% {
        background-position: 0% 50%
    }
    50% {
        background-position: 100% 50%
    }
    100% {
        background-position: 0% 50%
    }
}

.backlogo {
    animation: animate-banner 64s ease-in-out infinite
}
/* 横にスクロールさせるアニメーション */

@keyframes animate-banner {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-100%);
        transform: translateY(10);
    }
}

・後ろに流れる文字を表示する場合、以下のHTML要素を置く。
<div class="backlogo" style="
    font-weight: bold;
    font-size: 480rem;
    position: fixed;
    bottom: 0;
    z-index: -1;
    color: white;
    opacity: 0.25;
    text-align: center;
    line-height: 1;
    margin: 0;
    padding: 0;">TEST TEXT</div>


参考


https://tamatuf.net/html-css/css-background-gradient/


Category



Tag




関連記事


{{tmp.name}}

{{article.category}} {{article.title}}