CSS3动画-动画

animation 属性是一个简写属性,用于设置六个动画属性:
(1)、animation-name:需要绑定到选择器的 keyframe 名称
(2)、animation-duration:完成动画所需要的时间
(3)、animation-timing-function:动画的速度曲线,,其中有6个值
linear 动画从头到尾的速度是相同的
ease 默认。动画以低速开始,然后加快,在结束前变慢
ease-in 动画以低速开始
ease-out 动画以低速结束
ease-in-out 动画以低速开始和结束
cubic-bezier(n,n,n,n) 在 cubic-bezier 函数中自己的值。可能的值是从 0 到 1 的数值
(4)、animation-delay:动画开始之前的延迟
(5)、animation-iteration-count:动画的播放次数
n 定义动画播放次数的数值
infinite 规定动画应该无限次播放
(6)、animation-direction:是否应该轮流反向播放动画
normal 默认值,动画应该正常播放
alternate 动画应该轮流反向播放

下面的例子所产生的动画演示了一个正方形沿着正方形边框移动的效果。

div{
    width:100px;
    height: 100px;
    background-color: red;
    position: relative;
    animation:anmi 5s infinite alternate;//动画名为anmi,播放时间为5s,反向循环播放
    -webkit-animation:anmi 5s infinite alternate;//safari、chrome浏览器适配

}

@keyframes anmi{
    0%{background-color:red;left:0;top:0px}
    25%{background-color:blue;left:100px;top:0px}
    50%{background-color: #000000;left: 100px;top:100px}
    75%{background-color: gold;left: 0px;top:100px}
    100%{background-color: red;left: 0px;top: 0px;}
}//分别设置不同时间的动画效果

@-webkit-keyframes anmi {
     0%{background-color:red;left:0;top:0px}
     25%{background-color:blue;left:100px;top:0px}
     50%{background-color: #000000;left: 100px;top:100px}
     75%{background-color: gold;left: 0px;top:100px}
     100%{background-color: red;left: 0px;top: 0px;}
 }//safari、chrome浏览器适配
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值