Use the scrollTop method of jquery to monitor the vertical scrolling pixels of the page and hide or display the navigation bar on the top of the page based on the pixels. The specific implementation code is as follows, if you are interested, refer to the following section to use jquery's scrollTop method to monitor vertical scrolling pixels on the page and hide or display the navigation bar at the top of the page based on pixels.
Effect preview URL: http://www.keleyi.com/keleyi/phtml/scrolloversee.htm
ScrollTop introduction:
Syntax
$ (Selector). scrollTop (offset)
Parameters
Offset
Description
Optional. Specifies the offset relative to the top of the scroll bar, in pixels.
Definition and usage
The scrollTop () method returns or sets the vertical position of the scroll bar that matches the element.
Scroll top offset refers to the offset of the scroll bar relative to its top.
If no parameter is set for this method, the offset relative to the top of the scroll bar in pixels is returned.
Tips and comments
Note: This method is valid for both visible and invisible elements.
Note: When used to obtain a value, this method returns only the scroll top offset of the First Matching Element.
Note: When used to set the value, this method sets the scroll top offset of all matching elements.
Complete code is provided and saved to an html file. You can use the following code to access the html file:
The Code is as follows:
Monitor scroll pixels, show or hide top navigation bar-ke leyi