2012-03-16 39 views
1

歡迎。函數懸停 - 錯誤

我想得到的效果如下: 當你移動它的圖片出現div.description。離開後圖像div消失。

 <li> 
      <section class="projekt"> 
       <img src="images/projects/projekt1.jpg" alt=""> 
       <div class="description"> 

       </div> 
      </section> 
     </li> 

我要補充的是,DIV定位絕對descriprion圖片,並啓用了顯示:無; 下面的代碼,不幸的是它不應該像它應該。當你移動圖像出現在div中,但1秒後以100ms的速度消失,而不是保留。

$('section.projekt img').hover(
     function(){ 
      $(this).next().fadeIn(1000); 
     }, 
     function(){ 
      $(this).next().fadeOut(100); 
     } 
    ); 

感謝您的幫助提前。

回答

-1

你可以用CSS做:

.section:hover .description { 
    ... 
} 

對於 「變臉」 的效果,瞭解更多關於CSS animation

+0

的鼠標移開但你不會有淡入淡出效果。此外,問題是關於jQuery懸停,而不是CSS懸停:) – Fabian 2012-03-16 09:33:19

+0

@Fabian CSS動畫更容易使用,我試圖促進事情.. – 2012-03-16 09:37:00

0

的問題是描述DIV過來img,該發射IMG

$('section.projekt img').hover(
     function(){ 
      $(this).next().fadeIn(1000); 
      // add mouseout to description div not img 
      $(this).next().mouseout(function(){$(this).fadeOut(100);}) 
     } 
    );​