<h4>Scroll to see the sticky element <em>sticking</em></h4>
<div class="extra"></div>
<br />
<div id="wrapper">
<div id="sticky">
sticky element
</div>
</div>
<br />
<div class="extra"></div>
@import url('https://fonts.googleapis.com/css?family=Bellefair');
#sticky {
position: sticky;
position: -webkit-sticky;
background: lime;
width: 100px;
height: 100px;
top: 70px;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 0 6px lime;
color: #000;
}
.extra,
#wrapper {
width: 360px;
margin: auto;
background-color: #fff;
}
#wrapper {
height: 800px;
}
.extra {
height: 100px;
}
body {
font-family: Bellefair;
height: 1000px;
background: black;
font-size: 14pt;
}
h4 {
text-align: center;
color: white;
}
@media (min-height: 768px) {
#wrapper{
height: 2000px;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.