[英]jQuery UI Bounce Effect with CSS Sprite Image
我試圖讓我的社交圖標使用jQuery UI Bounce Effect彈跳。 我正在使用jQuery模板和一些文檔。 其余的我只是想自己編寫HTML,CSS和JS所以我可能在那里有一些錯誤。 我有一個問題讓圖標反彈。 我認為這可能是因為我使用精靈圖像作為社交圖標。
有人可以看看它並幫助我嗎?
標題中的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創建了一個即插即用的動畫庫,對於這樣的事情非常酷。
只使用CSS3就可以達到相同的彈跳效果。 @keyframes
和animation
屬性將完成這項工作。 這是JSFiddle中的工作示例。 每個圖像在hover
反彈。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.