我正試圖解決當鼠標懸停在一個div上時如何顯示隱藏剪切(facebook,google +,twitter)div的問題。如何使用jquery在鼠標懸停上顯示或隱藏社交分享按鈕div
以此爲共享一輪DIV的頂部右側的示例動畫:http://www.gethyapp.com/
請參閱我做了什麼:http://goo.gl/6XDM8
這裏是我的代碼已經完成:
HTML
<div class="share">share
<div class="line"></div>
<div class="facebook">fb</div>
<div class="google-plus">g+</div>
<div class="twitter">t</div>
</div>
CSS
.share{
background-color: #DA251D;
width: 50px;
height: 50px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
position: relative;
}
.share .facebook,
.share .google-plus,
.share .twitter,
.share .line {
display:none;
}
.facebook{
background-color: #FFFF00;
width: 0px;
height: 0px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
opacity: 0;
}
.google-plus{
background-color: #FFFF00;
width: 0px;
height: 0px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
opacity: 0;
}
.twitter{
background-color: #FFFF00;
width: 0px;
height: 0px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
opacity: 0;
}
.line{
width: 1px;
height: 200px;
background-color: #000;
position: absolute;
left: 30px;
}
個
JS
$(function(){
$(".share").hover(function(){
$(this).find(".line").delay(50).fadeIn().animate({width: 1, height: 200, opacity: 1, top:10},200);
$(this).find(".facebook").delay(100).fadeIn().animate({width: 32, height: 32, opacity: 1},400);
$(this).find(".google-plus").delay(300).fadeIn().animate({width: 32, height: 32, opacity: 1},400);
$(this).find(".twitter").delay(500).fadeIn().animate({width: 32, height: 32, opacity: 1},400);
}, function(){
$(this).find(".line").delay(50).fadeIn().animate({width: 1, height: 0, opacity: 0, top:-10},200)
$(this).find(".facebook").delay(500).animate({width: 0, height: 0, opacity: 0},400);
$(this).find(".google-plus").delay(300).animate({width: 0, height: 0, opacity: 0},400);
$(this).find(".twitter").delay(100).animate({width: 0, height: 0, opacity: 0},400);
});
});
我怎樣才能使它所以當你將鼠標懸停在分享框旁邊會顯示其他剪切框?
你能解釋一下嗎?你的問題是什麼? – ncm 2013-05-04 11:40:59
你的小提琴似乎工作,除了一些小的CSS問題可能......你到底想做什麼? – 2013-05-04 11:50:28
在懸停事件中添加一個函數並添加頁面加載時隱藏的div。 – 2013-05-04 11:52:40