CSS3 animation 属性实现“扫一扫”动画效果

制作这个扫一扫的动画,用了2张图片。一个是“方框的四个角(2.png)”,一个是“网格(4.png)”。

截图

使用css3 的animation属性,使“网格”从上往下移动,显示扫描效果。

<u>查看demo</u>

HTML结构

    <div class="bg">
    <div class="pane"></div>
    </div>

css样式

.bg, .pane {
            width: 200px;
            height: 200px;
            margin: 0 auto;
            overflow: hidden;  /* 隐藏显示区域外的内容*/
        }

        .bg {
            position: relative;
            background: url(images/2.png) center center no-repeat;
            border: 1px solid #b0f9e4;
        }

        .pane {
            position: absolute;
            z-index: -1;
            background: url(images/4.png) center center no-repeat;
            animation: move 1.5s ease-in-out infinite ;
            -webkit-animation: move 1.5s ease-in-out infinite;
        }

为网格设置animation动画,循环一次时长为 1.5s,ease-in-out动画由快到慢再到快结束动画,infinite无限循环。

        @keyframes move {
            from{top:-200px}  /*网格移动到显示区域的外面*/
            to{top:0}
        }
        -webkit-@keyframes move {
            from{top:-200px}
            to{top:0}
        }

定义move 动画,从上到下移动。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容