Search results
Description. The scrollTo() method scrolls the document to specified coordinates. Note. For the scrollTo() method to work, the document must be larger than the screen, and the scrollbar must be visible. See Also: The scrollBy () method. Syntax. window.scrollTo (x, y) or just: scrollTo (x, y) Parameters. Return Value. NONE. More Examples.
- Try It Yourself
The W3Schools online code editor allows you to edit code and...
- Scroll Indicator
Example. /* Style the header: fixed position (always stay at...
- Smooth Scroll
Smooth Scrolling. Add scroll-behavior: smooth to the <html>...
- Try It Yourself
Example. /* Style the header: fixed position (always stay at the top) */. .header {. position: fixed; top: 0; z-index: 1; width: 100%; background-color: #f1f1f1; }
Smooth Scrolling. Add scroll-behavior: smooth to the <html> element to enable smooth scrolling for the whole page (note: it is also possible to add it to a specific element/scroll container): Example. html { scroll-behavior: smooth; } Try it Yourself » Browser Support.
16 lis 2010 · If you want to set the scroll position of document.body, you can scroll the entire window altogether using window.scrollTo(); it takes either a pair of coordinates (x,y) or an options object – if you just want to scroll nicely to the top, try window.scrollTo({top:0,behavior:'smooth'});.
If you want to go the non- jQuery way, use the containing table's scrollTop property. Lets assume you can easily identify the row you want to scroll to using an ID, along with the containing <div />. Use the offsetTop of the element you want to scroll to. scrollTop is not supported by IE and Edge.
To get or set the scroll position of an element, you follow these steps: First, select the element using the selecting methods such as querySelector(). Second, access the scroll position of the element via the scrollLeft and scrollTop properties.
17 lip 2023 · The scroll-behavior CSS property sets the behavior for a scrolling box when scrolling is triggered by the navigation or CSSOM scrolling APIs.