Skip to content

Instantly share code, notes, and snippets.

@feo52
Created October 7, 2014 15:10
Show Gist options
  • Save feo52/e7af09b95e8d0ec96e49 to your computer and use it in GitHub Desktop.
Save feo52/e7af09b95e8d0ec96e49 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:1100px; height:6em; }
.containerS{ background:LightGrey; display:inline-block; width: 500px; height:6em; margin:0 300px; }
.marginL { background:Gainsboro; display:inline-block; width: 400px; height:2em; float:left; }
.marginS { background:Gainsboro; display:inline-block; width: 100px; height:2em; float:left; }
.stickyL { background:LightPink; display:inline-block; width: 100px; height:2em; float:left; text-align:center; line-height:2em; }
.stickyR { background:LightBlue; display:inline-block; width: 100px; height:2em; float:left; text-align:center; line-height:2em; }
.stickyC { background:LimeGreen; display:inline-block; width: 100px; height:2em; float:left; text-align:center; line-height:2em; }
.stickyL{
position: -webkit-sticky;
position: sticky;
left: 0px;
}
.stickyR{
position: -webkit-sticky;
position: sticky;
right: 0px;
}
.stickyC{
position: -webkit-sticky;
position: sticky;
left: 0px;
right: 0px;
}
</style>
</head>
<body>
change window-size.<br />
change scrollbar-position.<br />
<br />
<div class="containerL">
<div class="marginL"> </div><br />
<div class="stickyL">stickyL</div><br />
<div class="stickyC">stickyC</div><br />
<div class="stickyR">stickyR</div><br />
</div>
<br />
<br />
<div class="containerS">
<div class="marginS"> </div><br />
<div class="stickyL">stickyL</div><br />
<div class="stickyC">stickyC</div><br />
<div class="stickyR">stickyR</div><br />
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment