簡體   English   中英

scrollTop()沒有滾動到IE Windows 8手機上的正確位置

[英]scrollTop() is not scrolling to the correct place on IE windows 8 phone

盡管瀏覽器返回正確的高度,但它在任何地方都可以正常工作,但它滾動到錯誤的位置(每次都不同),這僅在IE W8手機上發生,以下是代碼:

$("#navigation-wrapper a").click(function(e){
    $headerHeight = $("#header").height();
    var $anchor = $(this);
    $('html, body').stop().animate({scrollTop: $($anchor.attr('href')).offset().top - $headerHeight});
e.preventDefault(); });

任何想法?

雖然這很麻煩,但是由於某種原因它起作用了。 為了滾動到正確的位置,我不得不兩次調用動畫。

$('html, body').stop()
  .animate({scrollTop: $($anchor.attr('href')).offset().top - $headerSize},function(){
      $('html, body').stop()
        .animate({scrollTop: $($anchor.attr('href')).offset().top - $headerSize});
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM