DEV Community

Bernard Faria
Bernard Faria

Posted on

You know position sticky?

position: sticky is a hybrid of position: relative and position: fixed. The element is treated as a relative position until it crosses a specified limit, when it is treated as a fixed position.

That is, if you want to make, for example, a header that is floating when you start scrolling, just use:

header {
  position: sticky;
  top: 0
}
Enter fullscreen mode Exit fullscreen mode

See the example

Top comments (0)