3

Have a look at following code snippet.

<div class="container">
    <div class="header" style="position:sticky;top:0">
        Header
    </div>
    <div class="content" style="position:static">
        Page content
        ...
    </div>
</div>

Here while scrolling page down, content goes below the header. All work as expected.

But if I change 'content' div positioning to relative, content starts to goes over the sticky header while scrolling page.

Why this happens? Is there a solution for this without using z-index?

hirantha129
  • 559
  • 1
  • 8
  • 19

0 Answers0