首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用css3关键帧动画的弹跳效果

问使用css3关键帧动画的弹跳效果
EN

Stack Overflow用户
提问于 2015-04-30 05:10:02
回答 1查看 1.4K关注 0票数 2

我正在尝试弹跳效果使用css3关键帧动画。以下是小提琴链接:click

盒子的背景在变化,但我的要求是给背景图像弹出效果,而不是背景颜色。

我到底需要什么:蹦床上弹跳(跳跃)泰迪有两种状态:

(1.手臂向上,2.手臂向下)跳跃时。

有什么办法可以实现吗?谢谢!

EN

回答 1

Stack Overflow用户

发布于 2015-04-30 05:56:25

我有办法解决这个问题

​

代码语言:javascript
复制
.margin{
    margin-top:200px;
}
} 
/* keyframes definition for WebKit browsers */

@-webkit-keyframes travel {
  from { right: 10px;     }
  to   { right: 10px; }
}

@-webkit-keyframes bounce {
  from, to  {
    bottom: 40px;
    -webkit-animation-timing-function: ease-out;
  }
  50% {
    bottom: 140px;
    -webkit-animation-timing-function: ease-in;
  }
}
@-webkit-keyframes bounce1 {
  from, to  {
    bottom: 40px;
    -webkit-animation-timing-function: ease-out;
  }
  50% {
    bottom: 140px;
	z-index:9;
    -webkit-animation-timing-function: ease-in;
  }
}


/* keyframes definition for other browsers */

@keyframes travel {
  from { right: 10px;     }
  to   { right:  10px;   }
}

@keyframes bounce {
  from, to  {
    bottom: 45px;
    animation-timing-function: ease-out;
  }
  50% {
    bottom: 140px;
    animation-timing-function: ease-in;
	
  }
}
@keyframes bounce1 {
  from, to  {
    bottom: 45px;
    animation-timing-function: ease-out;
  }
  50% {
    bottom: 140px;
	z-index:9;
    animation-timing-function: ease-in;
	
  }
}

/* styles for the stage and animated elements */

#traveler {
  position: absolute;
  width: 75px;
  height: 100px;
  -webkit-animation-name: travel;
  -webkit-animation-timing-function: linear;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-direction: alternate;
  -webkit-animation-duration:2.8s;

  animation-name: travel;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-direction: alternate;
  animation-duration: 2.8s;
}

#bouncer {
  position: absolute;
  width: 75px;
  z-index:10;
  height: 100px;
  border-radius: 10px;
  /*background: url(../img/jump.png) no-repeat;*/
    background:green;
  -webkit-animation-name: bounce;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-duration: 2.2s;

  animation-name: bounce;
  animation-iteration-count: infinite;
  animation-duration: 2.2s;
}
#bouncer2 {
  position: absolute;
  z-index:11;
  width: 75px;
  height: 100px;
  border-radius: 10px;
  /*background: url(../img/pyonpyon.png) no-repeat;*/
    background:red;
  -webkit-animation-name: bounce1;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-duration: 2.2s;

  animation-name: bounce1;
  animation-iteration-count: infinite;
  animation-duration: 2.2s;
}
代码语言:javascript
复制
<div class="margin">
<div id="traveler">
           <div id="bouncer"> </div>
		   <div id="bouncer2"> </div>
        </div>
</div>

​

小提琴例子:‘.’‘

谢谢

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29959451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档