简体   繁体   English

CSS3跳跃动画

[英]CSS3 jumping animation

I want to add a 3D jumping effect to a span using CSS3 animations. 我想使用CSS3动画为跨度添加3D跳跃效果。 I have uploaded one image that shows the direction. 我上传了一张显示方向的图片。

I tried using the following example, but the span jumps up and down. 我尝试使用以下示例,但是跨度会上下跳跃。 I need a 3D jumping effect. 我需要3D跳跃效果。 I have fiddled my demo here . 在这里摆弄我的演示。

The uploaded image is here . 上传的图片在这里

html html

<a class="bounce" href="#">hover me</a>

css 的CSS

*{

    background-color:yellow;

}
@-webkit-keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        -webkit-transform: translateY(0);
    }
    30% {
        -webkit-transform: translateY(30px);
    }
    100%{
        -webkit-transform: translateY(0px);
    }
}
.bounce:hover {
    -webkit-animation-name: bounce;
    -moz-animation-name: bounce;
    -o-animation-name: bounce;
    animation-name: bounce;
    -webkit-animation-duration:1s;
}

For consistent jumping you can try to use JQuery UI. 为了保持一致的跳跃,您可以尝试使用JQuery UI。 it will make the text jump as many times as you want. 它将使文本跳转任意多次。

$(document).ready(function(){
    $('.hover').effect('bounce', 4);
});

https://jsfiddle.net/JoshuaHurlburt/d846408x/2/ https://jsfiddle.net/JoshuaHurlburt/d846408x/2/

try playing with the easing on that animation 尝试播放该动画的缓动

cubic-bezier(0, 0, .58, 1) should do the trick cubic-bezier(0, 0, .58, 1)应该可以解决问题

updated fiddle https://jsfiddle.net/d846408x/3/ 更新小提琴https://jsfiddle.net/d846408x/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM