如何在悬停后继续CSS动画?

时间:2015-12-04 13:20:43

标签: html css animation

我制作一个带有动画img的按钮。所以当你盘旋时,汽车从左边开始,然后在中心停下来。当你徘徊时 - 汽车向右走。 我做了一个小提琴: https://jsfiddle.net/ufwyjd0o/

.button{
  height:150px;
  width: 150px;
  background-color:#468189;
  margin: 100px;
  border-radius: 100%;
  box-shadow: 0px 3px 8px 0px rgba(0,0,0,0.6);
  animation: size 1.5s infinite alternate;
  position: relative;
}

@keyframes size {
    0%   {transform: scale(1.0);
          box-shadow: 0px 3px 8px 0px rgba(0,0,0,0.6); }
    100% {transform: scale(1.05);
          box-shadow: 0px 8px 8px 0px rgba(0,0,0,0.4); }
}

.icon img{
  height:75px;
  width:auto;
  position: absolute;
  top: 40px;
  animation: driveout 1s cubic-bezier(.52,.02,.31,.99) both;
  transform: 1s;
}

@keyframes drive {
    0%   {transform: translate3d(-60px,0,0)}
    5%  {transform: translate3d(60px,0,0)}  
    10% {transform: translate3d(40px,0,0);}
}

@keyframes driveout {
    0%   {transform: translate3d(40px,0,0)} 
    100% {transform: translate3d(200px,0,0)}
}

.button:hover .icon img {
  animation: drive 10s  cubic-bezier(.52,.02,.31,.99) normal;
  animation-play-state: pause;
  display:block;
}

1 个答案:

答案 0 :(得分:-1)

如果您想在hoveron和hoverout上设置不同的动画(与javascript中的mouseover和mouseout相同),那么您最好的选择就是这样。

$profile = new Profile(array('user_id'=>$uid, 'gender'=>$input['gender'], 'age'=>$input['age'], 'address'=>$input['address']));