2017-05-08 100 views
0

我有JQuery代碼來動畫ScrollTop。動畫ScrollTop工作但不光滑

瀏覽器滾動到所需的位置,但不順利。

function scrollto_aboutUsSection(){ 
// alert("about us scroll called"); 
$("html,body").animate({scrollTop: $("#aboutUs_section").offset().top }, 0.001); 
} 

和HTML代碼是如下

<div id="container"> 

     <?php include("Includes/header&nav.html"); ?> 

     <div id="content"> 

      <?php include("Includes/information_section.html"); ?> 

      <section id = "aboutUs_section" class="Section"> 
       <h2 class="textShadow big_h2_font"> About Us </h2> 
       <p class="textShadow"> In 1987, Our founders laid the foundation of jewellery store in Gakhar Plaza, Saddar, Rawalpindi. Since that time we are in service in presentation of artistic jewels by the hands of talented craft persons and skilled artists. We still try our best to come up with ideas that matches with yours most, keeping the eye on craftmanships side by side. We deal in 21K, Embedded and non Embedded Jewels generally. 
       </br></br>If you are looking for 22K, we take orders as well. 
       </br></br>Visit our Gallery and have a look at our Jewels Range. </p> 
      </section> 
</div> </div> 

其它功能調用這個jQuery函數。

我已將<?php ?>包含在body標籤內的html代碼中。這個JQuery函數也調用頁面加載。所以不是它順利跳過動畫的原因。

之前PHP,它工作正常。

+1

給它一些時間動畫'0.001'意味着幾乎爲零...嘗試'500'例如,這是半秒。 – skobaljic

+0

是的,你是對的!我理解並解決了問題 –

回答

1

您使用的速度非常慢。使用此:中

$("html,body").animate({scrollTop: $("#aboutUs_section").offset().top }, 1000); 

通知的最後一個值,而不是10000.001

這是在毫秒的速度。所以1000是1秒。

+0

非常感謝。它幫助了我。 –