A Pen by Elad Shechter on CodePen.
Created
October 9, 2020 11:25
-
-
Save uschmelzer/60277efe690b7636c5598d6d60c9110c to your computer and use it in GitHub Desktop.
Positon Sticky
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<main class="main-container"> | |
<header class="main-header">HEADER</header> | |
<div class="main-content">MAIN CONTENT</div> | |
<footer class="main-footer">FOOTER</footer> | |
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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