Skip to content

Instantly share code, notes, and snippets.

@feo52
Created October 7, 2014 15:00
Show Gist options
  • Save feo52/27ddc3f6a033b1b070f0 to your computer and use it in GitHub Desktop.
Save feo52/27ddc3f6a033b1b070f0 to your computer and use it in GitHub Desktop.
position:sticky
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.containerL{ background:LightGrey; display:inline-block; width:45%; height:800px; float:left; }
.containerS{ background:LightGrey; display:inline-block; width:45%; height:400px; float:right; margin:200px 0; }
.marginL { background:Gainsboro; display:inline-block; width:10%; height:352px; }
.marginS { background:Gainsboro; display:inline-block; width:10%; height:152px; }
.stickyT { background:LightPink; display:inline-block; width:33%; height: 32px; float:left; text-align:center; line-height:32px; }
.stickyB { background:LightBlue; display:inline-block; width:33%; height: 32px; float:left; text-align:center; line-height:32px; }
.stickyM { background:LimeGreen; display:inline-block; width:33%; height: 32px; float:left; text-align:center; line-height:32px; }
.stickyT{
position: -webkit-sticky;
position: sticky;
top: 0px;
}
.stickyB{
position: -webkit-sticky;
position: sticky;
bottom: 0px;
}
.stickyM{
position: -webkit-sticky;
position: sticky;
top: 0px;
bottom: 0px;
}
</style>
</head>
<body>
change window-size.<br />
change scrollbar-position.<br />
<br />
<div class="containerL">
<div class="marginL"> </div><br />
<div class="stickyT">stickyT</div><br />
<div class="stickyM">stickyM</div><br />
<div class="stickyB">stickyB</div><br />
</div>
<div class="containerS">
<div class="marginS"> </div><br />
<div class="stickyT">stickyT</div><br />
<div class="stickyM">stickyM</div><br />
<div class="stickyB">stickyB</div><br />
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment