【CSS】smooth

説明

滑順滾動的屬性,讓網頁內引導<href=”#id”>的動作可以滑順地跳下來

瀏覽器支援度→Can I Use …

範例

方法一:指定CSS

a(href="#title")
 button click me

//這邊填充很多個br
h1#title title
*
 scroll-behavior: smooth

Display

方法二:指定JavaScript

button(onclick="scrollIt()") click me
function scrollIt(){
 
 window.scroll({
  top: 0,
  left: 0,
  behavior: "smooth"
 });

 
}

Display

Leave a Reply

Your email address will not be published. Required fields are marked *