Last active
August 29, 2015 14:08
-
-
Save GeorgeTzellis/69b5c726b83ebb681703 to your computer and use it in GitHub Desktop.
Position sticky
This file contains hidden or 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
/* Position sticky */ | |
section { | |
display: block; | |
margin: 3em; | |
height: 3000px; | |
width: 300px; | |
background: rgba(0, 0, 255, 0.3); | |
} | |
article { | |
heighjt: 5000px; | |
} | |
div { | |
position: sticky; | |
top: 10px; /* positional anchor needed to get sticky */ | |
z-index: 1; | |
counter-increment: headers; | |
} | |
div:nth-child(2n) { background-color:rgba(0, 0, 255, .2); } | |
div::after { | |
content: counter(headers); | |
float: right | |
} |
This file contains hidden or 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
<section> | |
<article> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
<div>Hello world</div> | |
</article> | |
</section> |
This file contains hidden or 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
// |
This file contains hidden or 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
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment