一、格式

中括号括起来的部分参数,实际写入中括号省略

animation: [name] [duration] [timingfunction] [delay] [iterationcount] [direction] [fillmode]

二、参数介绍

2.1 name

animation-name用于给@keyframes指定动画名称

animation-name
参数省略
单位 字符串
备注 设置则不使用动画

2.2 duration

即animationduration用于标记一个动画完成周期所需时间。非必填

animationduration
参数省略
单位 秒(s),毫秒(ms)
备注 默认0s,不设置则不使用动画

2.3 timingfunction

即animationtiming-function用于描述一个动画数值变化方式。非必填

animationtiming-function
参数省略
单位 字符串
备注 默认参数ease

参数表如下

2.4 delay

即animationdelay,用于标记一个动画完成周期所需时间。非必填

animationdelay
参数可省略
单位 秒(s),毫秒(ms)
备注 默认0s,不设置则不使用延时效果

值为正数时,表示动画延时启动。当值为负数时,表示动画超前启动直接从超前秒钟的动画处开始)。

2.5 iteration-count

即animation-iteration-count用于描述一个动画循环次数。非必填

animation-iteration-count
参数可省略
单位 整型字符
备注 默认0s,不设置则不使用循环播放效果

参数表如下

2.6 direction

即animation-direction,用于设置是否循环往复播放动画。非必填

animation-direction
参数可省略
单位 字符
备注 默认参数为normal

参数表如下

2.7 fillmode

即animation-fillmode用于在动画不播放时(处于延时完成状态)设置动画的位置。非必填样式可以分为在animation外部初始样式,以及在keyframes定义的动画样式

animation-direction
参数可省略
单位 字符
备注 默认参数为none

参数表如下

三、源码

<!DOCTYPE html>
<html>

<head>
    <title>animation</title>
</head>

<body>
    <!--<div class="dest-line"></div>-->
    <div class="eg-name">name</div>
    <div class="eg-duration-3s">drt3s</div>
    <div class="eg-duration-5s">drt5s</div>
    <div class="eg-timing-function-linear">linear</div>
    <div class="eg-timing-function-ease">ease</div>
    <div class="eg-timing-function-ease-in">ease-in</div>
    <div class="eg-timing-function-ease-out">ease-out</div>
    <div class="eg-timing-function-ease-in-out">ease-in-out</div>
    <div class="eg-timing-function-steps-step-3">step3</div>
    <div class="eg-timing-function-steps-step-30">step30</div>
    <div class="eg-timing-function-steps-start">start</div>
    <div class="eg-timing-function-steps-end">end</div>
    <div class="eg-timing-function-cubic-bezier1">bezier1</div>
    <div class="eg-timing-function-cubic-bezier2">bezier2</div>
    <div class="eg-delay-0s">delay0s</div>
    <div class="eg-delay-2s">delay2s</div>
    <div class="eg-delay--2s">delay-2s</div>
    <div class="eg-interation-count-2">ic-2</div>
    <div class="eg-interation-count-max">ic-max</div>
    <div class="eg-direction-normal">dir-nrml</div>
    <div class="eg-direction-reverse">dir-rvrs</div>
    <div class="eg-direction-alternate">dir-altr</div>
    <div class="eg-direction-alternate-reverse">dir-altr-re</div>
    <div class="eg-direction-initial">dir-intl</div>
    <div class="eg-direction-inherit">dir-inhrt</div>
    <div class="eg-fill-mode-none">flmd-none</div>
    <div class="eg-fill-mode-forwards">flmd-frwd</div>
    <div class="eg-fill-mode-backwards">flmd-bkwd</div>
    <div class="eg-fill-mode-both">flmd-both</div>
    <div class="eg-fill-mode-initial">flmd-intl</div>
    <div class="eg-fill-mode-inherit">flmd-inhrt</div>



</body>

</html>

<style>
    div {
        position: relative;
        width: 50px;
        height: 50px;
        opacity: 1;
        margin: 0px;
        padding: 0px;
        border-width: 2px;
        border-radius: 50px;
        border-color: aqua;
        border-style: solid;
        text-align: center;
        color: chartreuse;
        line-height: 20px;
        background-color: brown;
    }

    .dest-line {
        top: 0px;
        left: 290;
        width: 1px;
        height: 3000px;
        opacity: 1;
        margin: 0px;
        padding: 0px;
        border-width: 0px;
        border-color: black;
        border-style: solid;
        color: black;
        line-height: 0px;
        background-color: black;
    }

    .eg-name {
        animation: am1;
        /*eg2.1 [name]*/
    }

    .eg-duration-3s {
        animation: am1 3s;
        /*eg2.2 [name] [duration]*/
    }

    .eg-duration-5s {
        animation: am1 5s;
        /*eg2.2 [name] [duration]*/
    }

    .eg-timing-function-linear {
        animation: am1 5s linear;
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-ease {
        animation: am1 5s ease;
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-ease-in {
        animation: am1 5s ease-in;
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-ease-out {
        animation: am1 5s ease-out;
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-ease-in-out {
        animation: am1 5s ease-in-out;
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-steps-step-3 {
        animation: am1 5s steps(3);
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-steps-step-30 {
        animation: am1 5s steps(300);
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-steps-start {
        animation: am1 5s steps(3, start);
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-steps-end {
        animation: am1 5s steps(3, end);
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-cubic-bezier1 {
        animation: am1 5s cubic-bezier(0, 0, 1, 1);
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-timing-function-cubic-bezier2 {
        animation: am1 5s cubic-bezier(1, 0.2, 0, 0.8);
        /*eg2.3 [name] [duration] [timing-function]*/
    }

    .eg-delay-0s {
        animation: am1 5s linear 0s;
        /*eg2.3 [name] [duration] [timing-function] [delay]*/
    }

    .eg-delay-2s {
        animation: am1 5s linear 2s;
        /*eg2.3 [name] [duration] [timing-function] [delay]*/
    }

    .eg-delay--2s {
        animation: am1 5s linear -2s;
        /*eg2.3 [name] [duration] [timing-function] [delay]*/
    }

    .eg-interation-count-2 {
        animation: am1 5s linear 0s 2;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count]*/
    }

    .eg-interation-count-max {
        animation: am1 5s linear 0s infinite;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count]*/
    }

    .eg-direction-normal {
        animation: am1 5s linear 0s infinite normal;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction]*/
    }

    .eg-direction-reverse {
        animation: am1 5s linear 0s infinite reverse;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction]*/
    }

    .eg-direction-alternate {
        animation: am1 5s linear 0s infinite alternate;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction]*/
    }

    .eg-direction-alternate-reverse {
        animation: am1 5s linear 0s infinite alternate-reverse;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction]*/
    }

    .eg-direction-initial {
        animation: am1 5s linear 0s infinite initial;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction]*/
    }

    .eg-direction-inherit {
        animation: am1 5s linear 0s infinite inherit;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction]*/
    }

    .eg-fill-mode-none {
        animation: am2 5s linear 2s 2 normal none;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction] [fill-mode]*/
    }

    .eg-fill-mode-forwards {
        animation: am2 5s linear 2s 2 normal forwards;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction] [fill-mode]*/
    }

    .eg-fill-mode-backwards {
        animation: am2 5s linear 2s 2 normal backwards;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction] [fill-mode]*/
    }

    .eg-fill-mode-both {
        animation: am2 5s linear 2s 2 normal both;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction] [fill-mode]*/
    }

    .eg-fill-mode-initial {
        animation: am2 5s linear 2s 2 normal initial;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction] [fill-mode]*/
    }

    .eg-fill-mode-inherit {
        animation: am2 5s linear 2s 2 normal inherit;
        /*eg2.3 [name] [duration] [timing-function] [delay] [interation-count] [direction] [fill-mode]*/
    }

    @keyframes am1 {
        from {
            left: 0px;
        }

        to {
            left: 240px;
        }
    }

    @keyframes am2 {
        from {
            left: 0px;
            background-color: bisque;
        }

        to {
            left: 240px;
            background-color: chartreuse;
        }
    }
</style>

目前全部效果都已启用,如想要单独看某几条的效果,参考dest-line块中,使用<!–和–>屏蔽html语句即可

原文地址:https://blog.csdn.net/qq_34217861/article/details/125198276

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_42382.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注