html - webkit-animatoin 悬在半空中

标签 html css webkit

我有一个 webkit 动画代码,可以使球在悬停时上下弹跳, 问题是当光标没有尾随它悬卡在半空中的球时,所以基本上你必须上下跟随球才能工作。 我需要的是当光标接触到球时,球会自行反弹。

代码如下:

    .animated { 
        -webkit-animation-duration: 1s; 
        animation-duration: 1s; 
        -webkit-animation-fill-mode: both; 
        animation-fill-mode: both; 
        animation-play-state: paused; 
        -webkit-animation-iteration-count:infinite; 

    } 



    .animated:hover{
    	  animation-play-state: running; 
    }

@-webkit-keyframes bounce { 
    0%, 20%, 50%, 80%, 100% {-webkit-transform: translateY(0);} 
    40% {-webkit-transform: translateY(-30px);} 
    60% {-webkit-transform: translateY(-15px);} 
} 

@keyframes bounce { 
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);} 
    40% {transform: translateY(-30px);} 
    60% {transform: translateY(-15px);} 
} 

.bounce { 
    -webkit-animation-name: bounce; 
    animation-name: bounce; 
}

最佳答案

你错过了一个真正的动画

看这里 -- https://jsfiddle.net/9tvwkvdc/2/

例如,我只是添加了脉冲并添加了(当然可以将其更改为您想要的任何内容)

  animation-name: pulse;
  -webkit-animation-name: pulse;

此外 - 确保使用所有适当的供应商前缀。

你可以通过做这样的事情来浓缩你所拥有的一些东西 -

    -webkit-animation: pulse 1s infinite both paused; /* Safari 4+ */
    -moz-animation:    pulse 1s infinite both paused; /* Fx 5+ */
    -o-animation:      pulse 1s infinite both paused; /* Opera 12+ */
    animation:  pulse 5s infinite both paused;

关于html - webkit-animatoin 悬在半空中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30968448/

相关文章:

Javascript 如何使用函数 match()?

java - CellTable 中的 GWT TextColumn -> 水平对齐

html - 如何制作全 Angular Bootstrap 轮播 slider ?

uiwebview - 如何从 WKWebView 获取 JSContext

objective-c - 在 Cocoa WebView 中防止 Flash

javascript - 在javascript中检测webkit浏览器?

html - 可以有未定义的项目范围,还是我应该从可用模式中选择?

javascript - 多个谷歌图表 API,在同一网页上

jquery - Ruby on Rails CSS 不会刷新/重新加载每个页面更改

css - 设置变换后图像的宽度和高度 : rotate