The overscroll-behavior-y property is used to set the behavior of the browser when the vertical boundary of a scrolling area is reached. This can be used in websites where there are multiple scrolling areas and scrolling one area does not affect the page as a whole. This effect is known as scroll-chaining that can be enabled or disabled accordingly.
Syntax:
overscroll-behavior-y: auto | contain | none | initial | inherit
Property Values:
- auto: This is used to set the scrolling behavior to default on all the elements. The whole page will scroll even if the boundary of the element is reached. It is the default value.
Example:
<!DOCTYPE html><html><head><title>CSS | overscroll-behavior-y</title><style>.container {display: flex;}.main-content {width: 200px;background-color: lightgreen;}.smaller-box {overscroll-behavior-y: auto;height: 100px;width: 125px;margin: 25px;overflow-y: scroll;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>CSS | overscroll-behavior-y</b><p>overscroll-behavior-y: auto</p><divclass="container"><divclass="main-content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.<br><br>GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.</div><divclass="smaller-box">This is a smaller element that is alsoscrollable. The overscroll behaviorcan be used to control if the maincontent behind would scroll when thiselement's vertical boundary is reached.</div></div></body></html>Output: Scrolling down on the smaller element

- contain: It is used to set the scrolling behavior to default only on the element used. No scroll-chaining would occur on the neighboring scrolling areas and the elements behind will not scroll.
Example:
<!DOCTYPE html><html><head><title>CSS | overscroll-behavior-y</title><style>.container {display: flex;}.main-content {width: 200px;background-color: lightgreen;}.smaller-box {overscroll-behavior-y: contain;height: 100px;width: 125px;margin: 25px;overflow-y: scroll;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>CSS | overscroll-behavior-y</b><p>overscroll-behavior-y: contain</p><divclass="container"><divclass="main-content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.<br><br>GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.</div><divclass="smaller-box">This is a smaller element that is alsoscrollable. The overscroll behaviorcan be used to control if the maincontent behind would scroll when thiselement's vertical boundary is reached.</div></div></body></html>Output: Scrolling down on the smaller element

- none: It is used to prevent scroll-chaining on all elements. The default scroll overflow behavior is also prevented.
Example:
<!DOCTYPE html><html><head><title>CSS | overscroll-behavior-y</title><style>.container {display: flex;}.main-content {width: 200px;background-color: lightgreen;}.smaller-box {overscroll-behavior-y: none;height: 100px;width: 125px;margin: 25px;overflow-y: scroll;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>CSS | overscroll-behavior-y</b><p>overscroll-behavior-y: none</p><divclass="container"><divclass="main-content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.<br><br>GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.</div><divclass="smaller-box">This is a smaller element that is alsoscrollable. The overscroll behaviorcan be used to control if the maincontent behind would scroll when thiselement's vertical boundary is reached.</div></div></body></html>Output: Scrolling down on the smaller element

- initial: It is used to set the overscroll behavior to default value.
Example:
<!DOCTYPE html><html><head><title>CSS | overscroll-behavior-y</title><style>.container {display: flex;}.main-content {width: 200px;background-color: lightgreen;}.smaller-box {overscroll-behavior-y: initial;height: 100px;width: 125px;margin: 25px;overflow-y: scroll;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>CSS | overscroll-behavior-y</b><p>overscroll-behavior-y: initial</p><divclass="container"><divclass="main-content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.<br><br>GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. The portal alsohas dedicated GATE preparation andcompetitive programming sections.</div><divclass="smaller-box">This is a smaller element that is alsoscrollable. The overscroll behaviorcan be used to control if the maincontent behind would scroll when thiselement's vertical boundary is reached.</div></div></body></html>Output: Scrolling down on the smaller element

- inherit: It is used to set the scrolling behavior to inherit from the parent.
Supported Browsers: The browser supported by overscroll-behavior-y property are listed below:
- Chrome 63.0
- Firefox 59.0
- Opera 50.0


