Kiểu cuộn _
Thí dụ
Thêm hiệu ứng cuộn mượt mà vào trang:
document.documentElement.style.scrollBehavior = "smooth";
Định nghĩa và Cách sử dụng
Thuộc tính scrollBehavior chỉ định liệu có nên tạo hiệu ứng mượt mà cho vị trí cuộn, thay vì một bước nhảy thẳng, khi người dùng nhấp vào một liên kết trong một 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 |
Các trang liên quan
Tham chiếu CSS: thuộc tính hành vi cuộn
❮ Đối tượng phong cách