javascript - 带有 CSS Sprite 图像的 jQuery UI 弹跳效果

标签 javascript jquery html css sprite

我正在尝试使用 jQuery UI 弹跳效果让我的社交图标弹跳。我正在处理一个模板和一些来自 jQuery 的文档。其余的我只是想自己编写 HTML、CSS 和 JS,所以我可能在那里有一些错误。我在让图标弹跳时遇到问题。我认为这可能是因为我使用了 sprite 图像作为社交图标。

有人可以看一下并帮助我吗?

header 中的 jQuery 和 jQuery UI

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"</script>

正在使用的 CSS:

#footer {background:#1c1c1c; padding:40px 0 20px;  border-top:4px solid #fff;}
#footer a {color:#fff;}
#footer a:hover {color:#d5d5d5;}

#footer .social-icons {float:right;}
#footer .copyright img {float:left; margin-right:20px;}

#footer .copyright p {
font-size:80%;
line-height:140%;
}

#footer .social-icons { }
#footer .social-icons li.title {line-height:30px;}
#footer .social-icons li {margin:0 0 0 10px; }
#footer .social-icons li:first-child {margin-left:0;}

/* social icons */
.social-icons {margin:0 0 20px;}
.social-icons li {display:inline-block; margin:5px;vertical-align: middle;}
.social-icons li a {display:inline-block; width:30px; height:30px; text-indent:-9999px;     background-image:url(../images/social-icons-sprite.png); background-repeat: no-repeat;     position:relative; background-color: #111; -webkit-border-radius:3px; -moz-border-    radius:3px; border-radius:3px;
-webkit-transition: all 0.2s ease-out; -moz-transition: all 0.2s ease-out; -o-    transition: all 0.2s ease-out; transition: all 0.2s ease-out; }
.social-icons li a:hover {background-color:#cd2122; box-shadow:0 0 6px rgba(0,0,0,0.4)}

.social-icons li.social-twitter a {background-position:0 0;}
.social-icons li.social-dribbble a {background-position:-30px 0;}
.social-icons li.social-facebook a {background-position:-60px 0;}
.social-icons li.social-envato a {background-position:-90px 0;}

图标所在位置的 HTML。

<div id="footer">
        <div class="row">
            <div class="span12">
                <div class="bottom fixclear">
                    <ul class="social-icons fixclear">
                        <li class="title">SOCIAL LOVE</li>
                        <li class="social-twitter">
                            <a href="#">Twitter</a>
                        </li>
                    </ul>

最后,我认为需要正确插入和运行的JS。

<style type="text/css">
footer li.social-twitter {
width: 32px;
height: 32px;
}
</style>
<script>
$(document).ready(function() {

$("div").mouseenter(function () {
$(this).effect("bounce", { times:3 }, 270);
});

});
</script>

最佳答案

您可以使用@keyframes 动画来达到这种效果。

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

查看 Animate.css Dan Eden 创建了一个即插即用的动画库,对于此类事情来说非常酷。

关于javascript - 带有 CSS Sprite 图像的 jQuery UI 弹跳效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15605393/

相关文章:

javascript - Angular : scope variables

javascript - 在 Cordova Webview 中执行脚本

javascript - 如何使用JavaScript在SPOJ上提交解决方案?

jquery - float 菜单栏向上滚动时粘在顶部,一个替换另一个jquery

jquery - 在导航栏上的事件链接后面放置背景图像

javascript - 使用 ajax.send 将数据发送到 php

javascript - 根据页面滚动添加/删除类

html - 在我的主导航栏上方添加社交导航栏

javascript - HTML5 canvas 坐标应该使用 float 还是整数?

html - Markdown 中的 <video>