Created
February 18, 2020 10:25
-
-
Save i2r/954234800c77e27b770e1722dda56e99 to your computer and use it in GitHub Desktop.
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
/** | |
* Sticky | |
*/ | |
html, body { | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
height: 200%; | |
} | |
body { | |
margin: 0; | |
padding: 100px 100px 50%; | |
} | |
.first { | |
height: 100%; | |
background: green; | |
} | |
.second { | |
height: 50%; | |
} | |
.inner { | |
position: sticky; | |
top: 0; | |
color: white; | |
min-height: 60%; | |
width: 30%; | |
} | |
.second:first-child .inner { | |
background: red; | |
} | |
.second:last-child .inner { | |
background: blue; | |
} |
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
<div class="first"> | |
<div class="second"><div class="inner">sticky1</div></div> | |
<div class="second"><div class="inner">sticky2</div></div> | |
</div> |
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
// alert('Hello world!'); |
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","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