เลื่อน สไตล์คุณสมบัติพฤติกรรม
ตัวอย่าง
เพิ่มเอฟเฟกต์การเลื่อนที่ราบรื่นให้กับหน้า:
document.documentElement.style.scrollBehavior = "smooth";
ความหมายและการใช้งาน
คุณสมบัติ scrollBehavior ระบุว่าต้องการให้ตำแหน่งการเลื่อนเคลื่อนไหวอย่างราบรื่นหรือไม่ แทนที่จะกระโดดแบบตรง เมื่อผู้ใช้คลิกที่ลิงก์ภายในกล่องแบบเลื่อนได้
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
scrollBehavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
ไวยากรณ์
object.style.scrollBehavior = "auto|smooth|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
auto | Default. Allows a straight jump "scroll effect" between elements within the scrolling box. |
smooth | Allows a smooth animated "scroll effect" between elements within the scrolling box. |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
หน้าที่เกี่ยวข้อง
การอ้างอิง CSS: คุณสมบัติพฤติกรรมการเลื่อน
❮ สไตล์วัตถุ