码迷,mamicode.com
首页 > Web开发 > 详细

CSS Clip剪切元素动画实例

时间:2016-09-11 18:40:51      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

1.CSS

.fixed {
    position: fixed;
    width: 90px;
    height: 90px;
    background: red;
    border: 0px solid blue;
    left: 100px;
    top: 100px;
}

    .fixed:before {
        position: absolute;
        width: 100px;
        height: 100px;
        margin: -5px;
        content: ‘‘;
        box-shadow: inset 0px 0px 0px 2px blue;
        animation: animateOne linear 4s infinite;
    }

    .fixed:after {
        position: absolute;
        width: 100px;
        height: 100px;
        margin: -5px;
        content: ‘‘;
        box-shadow: inset 0px 0px 0px 2px blue;
        animation: animateOne linear 4s infinite;
        animation-delay: -2s; /*此处设置负值,提前进入指定状态*/
    }
@keyframes animateOne {
    0%,100% {
        clip: rect(0px,100px,5px,0px);
    }

    25% {
        clip: rect(0px,5px,100px,0px);
    }

    50% {
        clip: rect(95px,100px,100px,0px);
    }

    75% {
        clip: rect(0px,100px,100px,95px);
    }
}

注:

animation-delay 单独使用时注意两点:
1.需要放在animation属性后面
2.可以设置负数,调整动画开始的状态

显示结果:

技术分享

更多:

CSS Clip剪切元素实例

CSS Clip属性

CSS Clip剪切元素动画实例

标签:

原文地址:http://www.cnblogs.com/tianma3798/p/5862233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!