我試圖創建一個懸停效果,它將底層div帶到前面。jQuery Hovery Opacity閃爍
將底層div帶到前面已經通過z-index解決了。但是我的不透明度變化正在引起閃爍。當用戶將鼠標懸停在它上面時,它應該保持在0%,然後當它們移動光標時將它改回100%。有人知道我在做什麼錯嗎?
底層DIV是.under和在頂部的DIV是.IMG
#portfolio_content .img a { }
#portfolio_content .img a:hover { }
#portfolio_content .img {
display:block;
float:left;
height:210px;
margin:0 35px 35px 0!important;
overflow:hidden;
padding:0;
width:307px
}
#portfolio_content .img img {
display:block;
position:absolute!important;
overflow:hidden;
z-index:3!important
}
#portfolio_content .img img:hover { z-index:1!important }
#portfolio_content .img .title, #portfolio_content .img .title a {
font-size:22px;
margin:100px 0 10px 0;
float:left!important;
width:307px;
text-align:center;
position:relative!important
}
.desc {
font-size:13px;
display:block;
text-align:center!important;
margin:0 auto!important;
width:307px
}
.under {
z-index:2!important;
display:inline;
position:absolute;
width:307px;
height:210px;
background:transparent
}
.under:hover { z-index:4!important }
jQuery的
<!-- Hover Opacity -->
<script type="text/javascript">
$(document).ready(function(){
$("#portfolio_wrap .img img").hover(function(){
$(this).fadeTo("slow", 0.0); // This should set the opacity to 100% on hover
},function(){
$(this).fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
});
});
</script>
我相信這是因爲當你將鼠標懸停在DIV,你把跨度到前面;這使得你的鼠標技術上的跨度,這就像懸停* div的div。所以它消失了。 – Chad
@Chad:你應該把它當作答案,因爲它是正確的。 – rossipedia
將來,請不要問一個需要用戶訪問您的個人網站進行調試的問題。圖片始終是首選,因爲您不會被標記爲垃圾郵件,並且您的問題不會因被本地化而被封閉。謝謝。 – Will