Skip to content

Instantly share code, notes, and snippets.

@i2r
Last active June 23, 2020 10:06
Show Gist options
  • Save i2r/420eaa1baed7f00d418b3d4ffd79dda8 to your computer and use it in GitHub Desktop.
Save i2r/420eaa1baed7f00d418b3d4ffd79dda8 to your computer and use it in GitHub Desktop.
Sticky
/**
* 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: 20%;
width: 30%;
}
.second:first-child .inner {
background: red;
}
.second:last-child .inner {
background: blue;
}
<div class="first">
<div class="second"><div class="inner">sticky1</div></div>
<div class="second"><div class="inner">sticky2</div></div>
</div>
// alert('Hello world!');
{"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