CSS Tricks: Make It Sticky


Demo: Only view able in Firefox and Chrome browsers.

Scroll to see the sticky element sticking

Sticky Sticky Sticky

Sticky elements are elements on a page that don’t scroll out of view – they “stick to the visible area (viewport or scrolling box). You can create them with CSS using position: sticky;.

They act like relatively positioned elements before any scrolling and later like fixed elements once a scrolling threshold is reached. For now, only Firefox and Chrome support it.


<h4>Scroll to see the sticky element <em>sticking</em></h4>
<br />
<div id="wrapper">
  <div id="sticky">
    Sticky Sticky Sticky
<br />


#sticky {
  position: sticky;
  background: #F762BC;
  width: 340px;
  height: 100px;
  top: 10px;
  left: 5px;
  display: flex;
  box-shadow: 0 0 6px #000;
  text-shadow: 0 0 4px #fff
#wrapper {
  width: 75%;
  margin: auto;
  height: 800px;
  background-color: #c1c1c1;
  text-align: center;
Subscribe to the JqueryPlugins.net mailing list:
* indicates required


Pin It on Pinterest