純粋なcss3を使用して中心から周囲に広がる円のアニメーション効果コードを実現

高洛峰
リリース: 2017-03-16 10:13:46
オリジナル
2785 人が閲覧しました

まず簡単な例を見てみましょう。例:

@keyframes hovertreemove
{
from {top:30px;}
to {top:130px;}
}

Effect:
http ://hovertree.com/texiao/css3/37/1.htm

@keyframes ルールを通じてアニメーションを作成できます。

アニメーション作成の原則は、ある CSS スタイルのセットを別のスタイルのセットに徐々に変更することです。
この CSS スタイルのセットは、アニメーション処理中に複数回変更できます。
変更が発生する時間をパーセンテージで指定するか、0% と 100% に相当するキーワード「from」と「to」を使用して指定します。
0% はアニメーションの開始時間、100% はアニメーションの終了時間です。
ブラウザのサポートを最適化するには、常に 0% および 100% セレクターを定義する必要があります。

以下は上下移動のコードです:


<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>css3使用animation和@keyframes制作动画_何问起</title>
    <meta charset="utf-8" />
    <style>@keyframes hovertreemove{from {top:30px;}to {top:130px;}}
#hovertreekf{
    width:80px;height:80px;
    border:1px solid red;
    position:absolute;
    background:url(http://hovertree.com/themes/hvtimages/smile.png) no-repeat center;
    animation:hovertreemove /*动画样式名称*/
        1s /*动画时间*/
    linear /*线性运动*/
        infinite /*无限播放*/
        alternate/*往返动画*/;}
  a{color:blue;text-decoration:none;}  </style></head><body><a href="http://hovertree.com/h/bjaf/i309b77d.htm" target="_blank">说明</a>
    <p id="hovertreekf"></p></body></html>
ログイン後にコピー

以下は円形拡散移動のコードです:


<!DOCTYPE html><html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>纯css3圆形从中心向四周扩散动画效果_何问起</title>
    <style>
        @keyframes warn {
            0% {
                transform: scale(0.3);
                -webkit-transform: scale(0.3);
                opacity: 0.0;
            }

            25% {
                transform: scale(0.3);
                -webkit-transform: scale(0.3);
                opacity: 0.1;
            }

            50% {
                transform: scale(0.5);
                -webkit-transform: scale(0.5);
                opacity: 0.3;
            }

            75% {
                transform: scale(0.8);
                -webkit-transform: scale(0.8);
                opacity: 0.5;
            }

            100% {
                transform: scale(1);
                -webkit-transform: scale(1);
                opacity: 0.0;
            }
        }

        @keyframes warn1 {
            0% {
                transform: scale(0.3);
                -webkit-transform: scale(0.3);
                opacity: 0.0;
            }

            25% {
                transform: scale(0.3);
                -webkit-transform: scale(0.3);
                opacity: 0.1;
            }

            50% {
                transform: scale(0.3);
                -webkit-transform: scale(0.3);
                opacity: 0.3;
            }

            75% {
                transform: scale(0.5);
                -webkit-transform: scale(0.5);
                opacity: 0.5;
            }

            100% {
                transform: scale(0.8);
                -webkit-transform: scale(0.8);
                opacity: 0.0;
            }
        }

        .container {
            position: relative;
            width: 40px;
            height: 40px;
            /*border: 1px solid #000; hovertree.com */
        }
        /* 保持大小不变的小圆圈 何问起 */
        .dot {
            position: absolute;
            width: 92px;
            height: 92px;
            left: 120px;
            top: 120px;
            -webkit-border-radius: 50%;
            -moz-border-radius: 50%;
            border: 2px solid red;
            border-radius: 50%;
            z-index: 2;
        }
        /* 产生动画(向外扩散变大)的圆圈  */
        .pulse {
            position: absolute;
            width: 320px;
            height: 320px;
            left: 2px;
            top: 2px;
            border: 6px solid red;
            -webkit-border-radius: 50%;
            -moz-border-radius: 50%;
            border-radius: 50%;
            z-index: 1;
            opacity: 0;
            -webkit-animation: warn 2s ease-out;
            -moz-animation: warn 2s ease-out;
            animation: warn 2s ease-out;
            -webkit-animation-iteration-count: infinite;
            -moz-animation-iteration-count: infinite;
            animation-iteration-count: infinite;
            box-shadow: 1px 1px 30px red;
        }

        .pulse1 {
            position: absolute;
            width: 320px;
            height: 320px;
            left: 2px;
            top: 2px;
            border: 6px solid red;
            -webkit-border-radius: 50%;
            -moz-border-radius: 50%;
            border-radius: 50%;
            z-index: 1;
            opacity: 0;
            -webkit-animation: warn1 2s ease-out;
            -moz-animation: warn1 2s ease-out;
            animation: warn1 2s ease-out;
            -webkit-animation-iteration-count: infinite;
            -moz-animation-iteration-count: infinite;
            animation-iteration-count: infinite;
            box-shadow: 1px 1px 30px red;
        }a{color:blue;text-decoration:none;}
    </style></head><body><a href="http://hovertree.com/h/bjaf/i309b77d.htm" target="_blank">说明</a>
    <p class="container">
        <p class="dot"></p>
        <p class="pulse"></p>
        <p class="pulse1"></p>
    </p></body></html>
ログイン後にコピー

以上が純粋なcss3を使用して中心から周囲に広がる円のアニメーション効果コードを実現の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!