css-animation实现滚动的头像效果

前言:

        整理下css的 animation 效果,并实现一个滚动的头像效果

效果图:

实现方法:

.noReadImg{
  animation-name: playmusic;
  animation-duration: 4s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes playmusic {
  /* 起始位置 */
  from {
    transform: rotate(0deg);
  }
  /* 结束位置 */
  to {
    transform: rotate(360deg);
  }
}

 animation的api:

animation 属性是一个简写属性,用于设置六个动画属性:

  • animation-name 属性为 @keyframes 动画规定名称
  • animation-duration 属性定义动画完成一个周期所需要的时间,以秒或毫秒计。
//规定完成动画所花费的时间。默认值是 0,意味着没有动画效果。
​
请始终规定 animation-duration 属性,否则时长为 0,就不会播放动画了
  • animation-timing-function 规定动画的速度曲线。
1、
animation-timing-function:2s //从开头到结尾以相同的速度来播放动画
2、
animation-timing-function: linear
//linear   动画从头到尾的速度是相同的。
//ease     默认。动画以低速开始,然后加快,在结束前变慢。
//ease-in  动画以低速开始。
//ease-out 动画以低速结束。
//ease-in-out 动画以低速开始和结束。
3、
animation-timing-function: cubic-bezier(0,0,1,1);
//cubic-bezier(n,n,n,n) 在 cubic-bezier 函数中自己的值。可能的值是从 0 到 1 的数值。
  • animation-delay 属性定义动画何时开始。
animation-delay 值以秒或毫秒计。

提示:允许负值,-2s 使动画马上开始,但跳过 2 秒进入动画。
  • animation-iteration-count 属性定义动画的播放次数。
animation-iteration-count:2         //定义动画播放次数的数值。
animation-iteration-count:infinite  //规定动画应该无限次播放。
  • animation-direction 属性定义是否应该轮流反向播放动画。
animation-direction: normal|alternate; 
//normal    默认值。动画应该正常播放。
//alternate 动画应该轮流反向播放。

猜你喜欢

转载自blog.csdn.net/qq_41619796/article/details/131047243