css_贝塞尔曲线的变速与匀速

简介: css_animation

模拟animation效果

20210511110616311.gif

参考MDN文档说明:https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions
animation-timing-function常见的四种速率变化

  • ease 默认值,朝向动画中间的速度增加,最后逐渐减慢
  • ease-in 开始时会缓慢,随着动画属性过渡的速度增加,直到完成为止
  • ease-in-out 动画属性缓慢过渡,加速,然后再次减速
  • ease-out 开始很快,放慢动画的速度继续
  • linear 线性匀速

    实现模拟

    整体布局

    <div class='box'>
     <ul>
         <li>ease</li>
         <li>ease-in</li>
         <li>ease-in-out</li>
         <li>ease-out</li>
         <li>linear</li>
     </ul>
    </div>
    
    image.png

转换为1行5列

  • grid-template 网络划分
  • gap 间距
    ul{
         
         
     display: grid;
     grid-template:1fr/repeat(5,1fr);
     list-style: none;
     gap:1em;
    }
    li{
         
         
     text-align: center;
     color: #000000;
     text-transform: uppercase;
     height:50px;
     width: 100px;
     animation-name: move;
     animation-duration: 6s;
     animation-iteration-count:infinite;
    }
    

    动画

    下移80%;
    @keyframes move{
         
         
     to{
         
         
         transform: translateY(80vh);
     }
    }
    li:nth-child(1){
         
         
     background: #CAD3C8;
     animation-timing-function: ease;
    }
    li:nth-child(2){
         
         
     background: #3B3B98;
     animation-timing-function: ease-in;
    }
    li:nth-child(3){
         
         
     background: #B33771;
     animation-timing-function: ease-in-out;
    }
    li:nth-child(4){
         
         
     background: #25CCF7;
     animation-timing-function: ease-out;
    }
    li:nth-child(5){
         
         
     background: #EAB543;
     animation-timing-function: linear;
    }
    

    整体

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>annimation</title>
        <style>
            * {
    
    
                margin: 0;
                padding: 0;
            }

            body {
    
    
                width: 100vw;
                height: 100vh;
                background: #7f8fa6;
                display: grid;
                grid-template: 1fr/1fr;
            }

            .box {
    
    
                margin: 0 auto;
            }

            ul {
    
    
                display: grid;
                grid-template: 1fr/repeat(5, 1fr);
                list-style: none;
                gap: 1em;
            }

            li {
    
    
                text-align: center;
                color: #000000;
                text-transform: uppercase;
                height: 50px;
                width: 100px;
                animation-name: move;
                animation-duration: 6s;
                animation-iteration-count: infinite;
            }

            @keyframes move {
    
    
                to {
    
    
                    transform: translateY(80vh);
                }
            }

            li:nth-child(1) {
    
    
                background: #CAD3C8;
                animation-timing-function: ease;
            }

            li:nth-child(2) {
    
    
                background: #3B3B98;
                animation-timing-function: ease-in;
            }

            li:nth-child(3) {
    
    
                background: #B33771;
                animation-timing-function: ease-in-out;
            }

            li:nth-child(4) {
    
    
                background: #25CCF7;
                animation-timing-function: ease-out;
            }

            li:nth-child(5) {
    
    
                background: #EAB543;
                animation-timing-function: linear;
            }
        </style>
    </head>
    <body>
        <div class='box'>
            <ul>
                <li>ease</li>
                <li>ease-in</li>
                <li>ease-in-out</li>
                <li>ease-out</li>
                <li>linear</li>
            </ul>
        </div>
    </body>
</html>

结束

1122.gif

目录
相关文章
|
9月前
|
前端开发
css_animation运动的贝塞尔曲线
css_animation运动的贝塞尔曲线
40 0
|
Web App开发 前端开发
嘿,朋友,其实 CSS 动画超简单的 - 时间函数篇(贝塞尔曲线、steps,看完还不懂算我输)
时间函数在 CSS 动画中至关重要,它会直接影响到动画的展现效果,然而由于相对其它属性而言较为复杂,可能了解的人较少,今天详细讲一讲时间函数。
|
15天前
|
前端开发
【2025优雅草开源计划进行中01】-针对web前端开发初学者使用-优雅草科技官网-纯静态页面html+css+JavaScript可直接下载使用-开源-首页为优雅草吴银满工程师原创-优雅草卓伊凡发布
【2025优雅草开源计划进行中01】-针对web前端开发初学者使用-优雅草科技官网-纯静态页面html+css+JavaScript可直接下载使用-开源-首页为优雅草吴银满工程师原创-优雅草卓伊凡发布
33 1
【2025优雅草开源计划进行中01】-针对web前端开发初学者使用-优雅草科技官网-纯静态页面html+css+JavaScript可直接下载使用-开源-首页为优雅草吴银满工程师原创-优雅草卓伊凡发布
|
1月前
|
人工智能 程序员 UED
【01】完成新年倒计时页面-蛇年新年快乐倒计时领取礼物放烟花html代码优雅草科技央千澈写采用html5+div+CSS+JavaScript-优雅草卓伊凡-做一条关于新年的代码分享给你们-为了C站的分拼一下子
【01】完成新年倒计时页面-蛇年新年快乐倒计时领取礼物放烟花html代码优雅草科技央千澈写采用html5+div+CSS+JavaScript-优雅草卓伊凡-做一条关于新年的代码分享给你们-为了C站的分拼一下子
129 21
【01】完成新年倒计时页面-蛇年新年快乐倒计时领取礼物放烟花html代码优雅草科技央千澈写采用html5+div+CSS+JavaScript-优雅草卓伊凡-做一条关于新年的代码分享给你们-为了C站的分拼一下子
|
1月前
|
前端开发 JavaScript
【02】v1.0.1更新增加倒计时完成后的放烟花页面-优化播放器-优化结构目录-蛇年新年快乐倒计时领取礼物放烟花html代码优雅草科技央千澈写采用html5+div+CSS+JavaScript-优雅草卓伊凡-做一条关于新年的代码分享给你们-为了C站的分拼一下子
【02】v1.0.1更新增加倒计时完成后的放烟花页面-优化播放器-优化结构目录-蛇年新年快乐倒计时领取礼物放烟花html代码优雅草科技央千澈写采用html5+div+CSS+JavaScript-优雅草卓伊凡-做一条关于新年的代码分享给你们-为了C站的分拼一下子
54 14
【02】v1.0.1更新增加倒计时完成后的放烟花页面-优化播放器-优化结构目录-蛇年新年快乐倒计时领取礼物放烟花html代码优雅草科技央千澈写采用html5+div+CSS+JavaScript-优雅草卓伊凡-做一条关于新年的代码分享给你们-为了C站的分拼一下子
|
1月前
css3 svg制作404页面动画效果HTML源码
css3 svg制作404页面动画效果HTML源码
65 34
|
1月前
html+js+css实现的建筑方块立体数字时钟源码
html+js+css实现的建筑方块立体数字时钟源码
89 33
|
2月前
一个好看的小时钟html+js+css源码
一个好看的小时钟html+js+css源码
119 24

热门文章

最新文章