css动画

作者: 请叫我Bob | 来源:发表于2018-08-19 11:32 被阅读0次

如需在 CSS3 中创建动画,您需要学习 @keyframes 规则。

@keyframes 规则用于创建动画。在 @keyframes 中规定某项 CSS 样式,就能创建由当前样式逐渐改为新样式的动画效果。

实例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .mast{
            width: 722px;
            height: 344px;
            background-color: red;
            margin: 300px auto;
            position: relative;
            
            


        }
        .box{
            width: 64px;
            height: 166px;
            background-color: rgb(255,255,255);
            float: left;
            padding: 5px 10px;
            float: left;
            margin-left: 80px;
            margin-top: 50px;
            display: inline-block;
            animation: moving 1s ease 0s infinite alternate;


        }
        .box1{
            width: 64px;
            height: 166px;
            background-color: rgb(0,19,0);
            float: left;
            padding: 5px 10px;
            float: left;
            margin-left: 31px;
            margin-top: 50px;
            display: inline-block;
            animation: moving 1s ease 0.1s infinite alternate;

        }
        .box2{
            width: 64px;
            height: 166px;
            background-color: rgb(173,255,46);
            float: left;
            padding: 5px 10px;
            float: left;
            margin-left: 31px;
            margin-top: 50px;
            display: inline-block;
            animation: moving 1s ease 0.2s infinite alternate;

        }
        .box3{
            width: 64px;
            height: 166px;
            background-color: rgb(255,193,205);
            float: left;
            padding: 5px 10px;
            float: left;
            margin-left: 31px;
            margin-top: 50px;
            display: inline-block;
            animation: moving 1s ease 0.3s infinite alternate;

        }
            

        
        .box4{
            width: 64px;
            height: 166px;
            background-color: rgb(0,255,255);
            float: left;
            padding: 5px 10px;
            float: left;
            margin-left: 31px;
            margin-top: 50px;
            display: inline-block;
            animation: moving 1s ease 0.4s infinite alternate;

        }

        

            @keyframes moving{
                from{
                    transform: scaleY(1);
                }
                to{
                    transform: scaleY(0.5);
                    

                }
            }
            h1{
                display: inline-block;
                position: absolute;
                top: 250px;
                left:300px;

                

            }
    </style>
</head>
<body>
    <div class="mast">
        <div class="box"></div>
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="box3"></div>
        <div class="box4"></div>
        <h1>loading...</h1>
    </div>  


    
</body>
</html>

动画效果:


相关文章

  • CSS-3D知识

    1.CSS动画 1.1 CSS动画属性-animation animation:为CSS动画属性,使用该属性可以替...

  • Css动画 小球横移

    学习css 动画,建立小球左右横移的动画原料:html5 Css3html CSS css 动画属性介绍 其中an...

  • 网页高级知识点(三)

    CSS3 transition动画 CSS3 transform变换 CSS3 animation动画

  • 有用的Vue第三方库

    Animate.css - CSS动画库 Velocity.js - JS动画库 TweenJS - 状态过渡动画...

  • 动画类文章

    css3常用动画+动画库 vue2使用animate css

  • Vue.js 过渡动画

    1. css实现过度 transition 动画 css-transform动画 动态组件 上述动画,如果设置mo...

  • 前端开发入门到实战:CSS动画@keyframes的用法

    CSS动画 CSS动画允许大多数HTML元素的动画,而无需使用JavaScript或Flash! 动画浏览器支持 ...

  • 2018-06-13

    Css动画: css3动画主要包括Transform、Transition、Animation 区别 transi...

  • 2018-08-15

    CSS动画 CSS3 @keyframes 规则如需在 CSS3 中创建动画,您需要学习 @keyframes 规...

  • CSS3 动画

    动画属性 动画(animation)是CSS3新增的属性,动画属性可以为元素创建动画,CSS3以前在网页上实现动画...

网友评论

      本文标题:css动画

      本文链接:https://www.haomeiwen.com/subject/flcciftx.html