Thuộc tính cuộn kiểu hành vi
Ví dụ
Thêm hiệu ứng cuộn mượt mà vào một trang:
document.documentElement.style.scrollBehavior = "smooth";
Hãy tự mình thử »Sự miêu tả
Thuộc tính ScrollBehavior chỉ định xem có tạo hiệu ứng mượt mà cho vị trí cuộn hay không, thay vì nhảy thẳng, khi người dùng nhấp vào liên kết trong hộp có thể cuộn.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
scrollBehavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
Cú pháp
object .style.scrollBehavior = "auto|smooth|initial|inherit"
Giá trị tài sản
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 |
Trang liên quan
Tham chiếu CSS: thuộc tính hành vi cuộn