scroll
Like on, scroll also accepts a single event action as input.
This feature scrolls the element.
Custom elements (e.g. Web Components) can also be made scrollable; all they must do is implement the standard scroll and scrollBy methods.
scroll provides a set of optional attributes for customizing its behavior.
These are covered in the sections below.
behavior¶
Warning
Smooth scrolling is disabled because of your system’s motion settings.
You can enable it here:
- Windows: Settings → Accessibility → Visual effects → Animation effects
- macOS: System Settings → Accessibility → Display → Reduce motion
- iOS: Settings → Accessibility → Motion → Reduce Motion
- Android: Settings → System → Accessibility → Remove animations
- Firefox:
about:config-> addui.prefersReducedMotion(number) and set it to0or1. This overrides the system setting.
Specifies whether the scrolling should animate smoothly (smooth), happen
instantly in a single jump (instant), or let the browser choose
(auto, default).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
relative¶
This is a boolean attribute. When present, scrolling uses relative offsets instead of an absolute position.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
top¶
Specifies how much to scroll vertically.
Can be set to one of the following:
- a numeric pixel value
startto scroll all the way to the topcenterto scroll to the middleendto scroll all the way to the bottom
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
left¶
Specifies how much to scroll horizontally.
Can be set to one of the following:
- a numeric pixel value
startto scroll all the way to the leftcenterto scroll to the middleendto scroll all the way to the right
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |