2014-01-12 38 views
0

我已經做了放大鏡上的動畫來移動懸停,但我沒有衝突,我不知道爲什麼它不工作。放大鏡與jquery上的動畫

http://www.kirstymarks.com/

請參閱下面我的代碼: -

$(document).ready(function() { 
$('#ie8 .image-info').css('opacity', '0'); 
    if ($('#ie8 .image-info').length){ 
      $('.entry-image').hover(function(){ 
       $(this).find('.image-info').css('opacity', '1'); 
      }, function(){ 
       $(this).find('.image-info').css('opacity', '0'); 
      }); 
     }; 
}); 
$('.thumbnailwrap .readmore').hover(
      function(){ 
       $(this).find('span').stop(true,true).animate({ 'top' : '-24px', 'opacity' : '0' }, 150, function(){ 
        $(this).css({ 'top' : '86px' }).animate({ 'top' : '9px', 'opacity' : '1' }, 150); 
       }); 
      }, function(){ 
       $(this).find('span').css({ 'top' : '9px', 'opacity' : '1' }).stop(true,true).animate({ 'top' : '46px', 'opacity' : '0' }, 150, function(){ 
        $(this).css({ 'top' : '-24px', 'opacity' : '1' }).animate({ 'top' : '9px' }, 150); 
       }); 
      } 
     ); 

指針是讚賞的傢伙,我不想要的答案,我會愛來教育自己如何我已經錯以上。

什麼,我想重新創建的例子是這樣的: -

http://elegantthemes.com/preview/Origin/

+0

嘗試把'$(文件).ready'函數內部懸停功能? – Bill

+1

定義「不工作」。 – Blazemonger

+0

在懸停它應該飛起來,並按照CSS函數回來,比利,這將是明智的? –

回答

1

謝謝讓康納在JS聊天的答案。這就是我一直在尋找: -

$(function() { 
$('.readmore').hover(function() { 
    $('span').stop().animate({ 
     top: '-24px', 
     opacity: 0 
    }, 150, function() { 
     $(this).css({ 
      top: '86px' 
     }).animate({ 
      top: '9px', 
      opacity: 1 
     }, 150); 
    });  
}, function() { 
    $(this).find('span').css({ 
     top: '9px', 
     opacity: 1 
    }).stop().animate({ 
     top: '46px', 
     opacity: 0 
    }, 150, function() { 
     $(this).css({ 
      top: '-24px', 
      opacity: 1 
     }).animate({ 
      top: '9px' 
     }, 150); 
    }); 
}); 
}); 

的這個例子: -

http://jsfiddle.net/rusticblonde/T9Gw7/25/

+0

請解釋你的答案..你有什麼改變? – Bill

+0

嗨比利,這是我正在尋找,它的工作原理。你給我的例子很棒,但它並沒有真正向我解釋如何對它進行動畫處理,上面是我要求的例子 –

+0

但是沒有區別..你的代碼不工作的原因是因爲(*請參閱我的答案*) – Bill

0

hover功能需要在您的$(document).ready函數中。

請參閱我的JsFiddle

我已經做了另一個jsFiddle告訴你同樣的事情,但與.animate而不是.css(即使它是完全不相關的問題)。

+0

嗨比利,感謝這一點,我不知道如何將它應用到我自己的示例頭腦,因爲即時通訊使用動畫功能而不是.css。但謝謝你的例子,我會看看我能做些什麼:) –

+0

這不是你的動畫函數,請參閱[這個小提琴](http://jsfiddle.net/2GntL/3/)的更新版本與動畫而不是css。問題是你的整個懸停功能需要在'$(document).ready'裏面 – Bill