คุณสมบัติเลื่อนพฤติกรรม CSS
ตัวอย่าง
เพิ่มเอฟเฟกต์การเลื่อนที่ราบรื่นให้กับเอกสาร:
html {
scroll-behavior: smooth;
}
ความหมายและการใช้งาน
คุณสมบัติscroll-behavior
ระบุว่าต้องการให้ตำแหน่งการเลื่อนเคลื่อนไหวอย่างราบรื่นหรือไม่ แทนที่จะกระโดดแบบตรง เมื่อผู้ใช้คลิกที่ลิงก์ภายในกล่องแบบเลื่อนได้
ค่าเริ่มต้น: | รถยนต์ |
---|---|
รับการถ่ายทอด: | ไม่ |
เคลื่อนไหวได้: | ไม่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSSOM ดูโมดูล (ร่างการทำงาน) |
ไวยากรณ์ JavaScript: | วัตถุ .style.scrollBehavior="smooth" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
scroll-behavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
ไวยากรณ์ CSS
scroll-behavior: auto|smooth|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description |
---|---|
auto | Allows a straight jump "scroll effect" between elements within the scrolling box. This is default |
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 |