2014-09-03 51 views
0

我正在修復圖像my site產品頁面。圖像應根據選項進行修正。添加以下代碼,但圖像浮在內容上面也..如何修復圖片的限制?

var images = jQuery('.single-product .images'); 

jQuery.fn.followTo = function (pos) { 
    var $this = this, 
    $window = jQuery(window); 

$window.scroll(function (e) { 
    if ($window.scrollTop() > pos) { 
     $this.css({ 
      position: 'absolute', 
      top: pos - $this.height() 
     }); 
    } else { 
     $this.css({ 
      position: 'fixed', 
      top: 'auto' 


     }); 
    } 
}); 
}; 

images.followTo(jQuery('#myTab').offset().top - images.height()); 

我還與0,100試圖在「自動」不同的值,但沒有工作 請幫我解決這個問題?謝謝!

更新 enter image description here

+0

我想修復圖像,並與選項中滾動。但不需要在內容上方滾動。 – Subha 2014-09-03 07:41:40

回答

0

的Javascript

$.fn.followTo = function (pos) { 
    var $this = this, 
     $window = $(window); 

    $window.scroll(function (e) { 
     if ($window.scrollTop() > pos) { 
      $this.css({ 
       position: 'absolute', 
       top: pos 
      }); 
     } else { 
      $this.css({ 
       position: 'fixed', 
       top: 0 
      }); 
     } 
    }); 
}; 

$('#yourDiv').followTo(250); 

的jsfiddle jsfiddle

更新1:

images.followTo(($("#myTab").offset().top)-(images.offset().top)- images.outerHeight()); 

JSFiddle

+0

沒有變化,結果相同。 – Subha 2014-09-03 07:47:32

+0

(「.product_info_left」)。followTo(250); – Hamix 2014-09-03 07:52:12

+0

只需要圖像滾動到空白區域,無需重疊內容,它會在製表符開始時停止。 – Subha 2014-09-03 07:55:11