Skip to content

Instantly share code, notes, and snippets.

@uschmelzer
Created October 9, 2020 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uschmelzer/60277efe690b7636c5598d6d60c9110c to your computer and use it in GitHub Desktop.
Save uschmelzer/60277efe690b7636c5598d6d60c9110c to your computer and use it in GitHub Desktop.
Positon Sticky
<main class="main-container">
<header class="main-header">HEADER</header>
<div class="main-content">MAIN CONTENT</div>
<footer class="main-footer">FOOTER</footer>
</main>
body{color:#fff; font-family:arial; font-weight:bold; font-size:40px; }
.main-container{ max-width:600px; margin:0 auto; border:solid 10px green; padding:10px; margin-top:40px;}
.main-container *{padding:10px;background:#aaa; border:dashed 5px #000;}
.main-container * + *{margin-top:20px;}
.main-header{
height:50px; background:#aaa; border-color:red;
}
.main-content{
min-height:1000px;
}
.main-header{position:-webkit-sticky; position:sticky; top:0;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment