Fixed position but relative to container

后端 未结 25 1635
独厮守ぢ
独厮守ぢ 2020-11-21 23:52

I am trying to fix a div so it always sticks to the top of the screen, using:

position: fixed;
top: 0px;
right: 0px;

However,

相关标签:
25条回答
  • 2020-11-22 00:47

    When you use position:fixed CSS rule and try to apply top/left/right/bottom it position the element relative to window.

    A workaround is to use margin properties instead of top/left/right/bottom

    0 讨论(0)
提交回复
热议问题