animation动画知识点

keyframes包括初始属性和最终属性,一个开始执行的动作时间和一个延续动作时间以及动作的变换速率。比如说第一个时间段执行什么动作,第二个时间段执行什么动作。
命名有@keyframes开头 紧接动画名称加上{},括号中间是由多个从0%到100%构成的,分别给每个百分比加上不同动作属性,比如说移动、颜色、位置、大小,from相当于0%;to相当于100%
在这里插入图片描述

@-webkit-keyframes 'wobble' {
   0% {
      margin-left: 100px;
      background: green;
   }
   40% {
      margin-left: 150px;
      background: orange;
   }
   60% {
      margin-left: 75px;
      background: blue;
   }
   100% {
      margin-left: 100px;
      background: red;
   }
}
@Keyframes定义好后,开始调用animation属性
.demo1 {
	-webkit-animation-name:'wobble';/*动画属性名,也就是我们前面keyframes定义的动画名*/
	-webkit-animation-duration: 10s;/*动画持续时间*/
	-webkit-animation-timing-function: ease-in-out; /*动画频率,和transition-timing-function是一样的*/
	-webkit-animation-delay: 2s;/*动画延迟时间*/
	-webkit-animation-iteration-count: 10;/*定义循环资料,infinite为无限次*/
	-webkit-animation-direction: alternate;/*定义动画方式*/  
} 

案例

在这里插入图片描述

/*给方型box一个初步样式*/
a.box {
  display: block;
  width: 50px;
  height: 50px;
  background: red;
  margin-bottom: 20px;
}
/*圆型box的样式,并在这里应用animation*/
a.round {
  -webkit-border-radius: 25px;
  -moz-border-radius: 25px;
  border-radius: 25px;
  background: green;
  -webkit-animation-name: 'round'; /*动画名称*/
  -webkit-animation-duration: 60s;/*播放一次所持续时间*/
  -webkit-animation-timing-function: ease;/*动画播放频率*/
  -webkit-animation-iteration-count: infinite;/*动画播放次涒为无限次*/
}      
/*click button效果*/
.click-btn {
    background: rgba(125,220,80,0.8);
    -moz-border-radius: 5px;
   -webkit-border-radius: 5px;
    border-radius: 5px;
    -webkit-box-shadow: inset 0 0 8px rgba(255,255,255,0.8),0 0 10px rgba(10,255,120,0.3);
    -moz-box-shadow: inset 0 0 8px rgba(255,255,255,0.8),0 0 10px rgba(10,255,120,0.3);
    box-shadow: inset 0 0 8px rgba(255,255,255,0.8),0 0 10px rgba(10,255,120,0.3);
    padding: 5px 10px;
    color: #369;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.5);
    cursor: pointer;
}
@-webkit-keyframes 'round' {
     from{
       -webkit-transform: rotate(36deg);
       -webkit-border-radius: 2px;
     }
  10%{
      -webkit-transform: rotate(72deg);
      -webkit-border-radius: 4px;
     }
  20% {
      -webkit-transform: rotate(108deg);
      -webkit-border-radius: 6px;
    }
  30% {
      -webkit-transform: rotate(144deg);
      -webkit-border-radius: 9px;
    }
  40%{
     -webkit-transform: rotate(180deg);
     -webkit-border-radius: 12px;
  }
  50%{
     -webkit-transform: rotate(216deg);
     -webkit-border-radius: 14px;
  }
  60% {
     -webkit-transform: rotate(252deg);
     -webkit-border-radius: 16px;
  }
  70% {
     -webkit-transform: rotate(288deg);
     -webkit-border-radius: 19px;
  }
  80%{
     -webkit-transform: rotate(324deg);
     -webkit-border-radius: 22px;
  }
  to {
     -webkit-transform: rotate(360deg);
     -webkit-border-radius: 25px;
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值