Skip to content
Related Articles

Related Articles

Improve Article
CSS | Scroll Snap stop
  • Last Updated : 30 Sep, 2019

The Scroll Snap stop property is an inbuilt property in the Scroll Snap module. The Scroll Snap stop property stops or you can lock the scroll at some specific position that you define. It works like there is a pattern in your every slide and when the user scrolls the slide the pattern automatically changed and fits into the background and fixes the position of your content. It is an optional property in the scroll snap module.

The Scroll Snap stop property lets the developer to stop the user scroll action at a particular position. Suppose the user scrolls the page by a gigantic scroll of the wheel then normally the scrolling will stop at the end of the scroll point when there is nothing left to visit on that page. But with this property developer tell the browser where to stop that does not matter how gigantic the scroll was.

Syntax:

scroll-snap-stop: normal | always;

Parameter: This property accepts only two parameter that mentioned above and described below:

  • normal: This property is the default value. The browsers pass through the snapping position does not stop any specific position.
  • always: This property enable the stop at snapping position.

Example: Below example illustrates the Scroll Snap stop property:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        CSS Scroll Snap Stop
    </title>
    <style>
        h1 {
            color: green;
        }
          
        .container {
            display: flex;
            overflow: auto;
            outline: 2px solid black;
            flex: none;
        }
          
        .container.y {
            width: 320px;
            height: 200px;
            flex-flow: column nowrap;
        }
          
        .container > div {
            text-align: center;
            scroll-snap-align: center;
            flex: none;
        }
          
        .y.container > div {
            line-height: 150px;
            font-size: 60px;
            width: 300px;
            height: 180px;
        }
          
        .y.proximity-scroll-snapping {
            scroll-snap-type: y proximity;
        }
        .proximity-scroll-snapping > div {
             scroll-snap-stop: always;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h4>CSS Scroll Snap Stop</h4>
        <div class="container y proximity-scroll-snapping">
            <div style="background:green;">Geeks</div>
            <div style="background:cyan;">HTML</div>
            <div style="background:brown;">CSS</div>
            <div style="background:purple;">JavScript</div>
            <div style="background:yellow;">Bootstrap</div>
        </div>
    </center>
</body>
  
</html>                    

Output:

Supported Browsers: The browsers supported by CSS Scroll Snap Stop are listed below:

  • Google Chrome 69
  • Internet Explorer 11
  • Firefox 68
  • Safari 11



My Personal Notes arrow_drop_up
Recommended Articles
Page :