2016-03-16 87 views
0

我試圖讓2套類在jQuery中有固定位置。滾動固定位置= jQuery Jank與Safari中的偏移頂部

$(window).scroll(function(){ 

    $(".staticTextGrid").each(function(){ 

     $(this).css('margin-top',($(window).scrollTop() - $(this).parent().offset().top+160)); 

    }); 
    $(".staticTextGridTop").each(function(){ 

     $(this).css('margin-top',($(window).scrollTop() - $(this).parent().offset().top)); 

    }); 
}); 

這就是我正在做的,但它不想在Safari瀏覽器中播放很好(導致它抖動和抖動)。任何正確的方向點都會很棒。我提前感謝。

回答

0

你還沒有說什麼野生動物園正在做的事情不是很好玩,所以我只能刺傷它。但有時Safari瀏覽器不會在CSS更改中再次顯示頁面。嘗試將其添加到函數的末尾。這不是最好的解決方案,但它至少會證實問題! :)

$("body").addClass("tempClass").removeClass("tempClass"); 
+0

嘿謝謝你的迴應,並抱歉不清楚。它在safari中引起騷動。在其他瀏覽器中不存在的緊張不安的口吃。我嘗試了你的建議,但仍然感到不安。任何其他刺傷它會很好。謝謝。 – billNugz

+0

好吧在safari或IE中檢查這個小提琴,https://jsfiddle.net/billNugz/y4x1cbcz/ 它顯示抖動。任何幫助都會很棒。並支持http://ianlunn.co.uk爲我提供了一個基礎。 – billNugz