Snippets Collections
<html>
    <head>
        <style>
  
  			/* Sticky - position: sticky is a mix of position: relative and position: fixed. It acts like a relatively positioned element until a certain scroll point and then it acts like a fixed element. Have no fear if you don't understand what this means, the example will help you to understand it better. */
  			.main-element {
                  position: sticky;
                  top: 10px;
                  background-color: yellow;
                  padding: 10px;
              }

              .parent-element {
                  position: relative;
                  height: 800px;
                  padding: 50px 10px;
                  background-color: #81adc8;
              }
  		
        </style>
    </head>
	<body>
        <div class="parent-element">
            <div class="sibling-element">
                I'm the other sibling element.
            </div>
            
            <div class="main-element">
                All eyes on me. I am the main element.
            </div>
            
            <div class="sibling-element">
                I'm the other sibling element.
            </div>
        </div>
    </body>
<html>
#page .page-section {position: sticky!important; top: 0px!important} html {scroll-behavior: smooth} 

Here is the code from this tutorial with a little bit of a shadow to create even more depth between these pages sections. 

#page .page-section {position: sticky!important; top: 0px; box-shadow: 5px 5px 15px rgba(0,0,0,0.8)!important} html {scroll-behavior: smooth}
star

Tue Sep 13 2022 07:45:20 GMT+0000 (Coordinated Universal Time) https://www.freecodecamp.org/news/learn-the-basics-the-css-position-property/

#css #position #sticky
star

Tue Mar 15 2022 13:06:02 GMT+0000 (Coordinated Universal Time) https://insidethesquare.co/squarespace-tutorials/summary-hover-effects-62te9

#sticky #scroll #sections

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension