body { overflow-x: hidden; } breaks position: sticky

后端 未结 3 1866
悲哀的现实
悲哀的现实 2020-12-03 20:53

I have an element that I am making sticky with position sticky:

#header {
    position: sticky;
    width: 100vw;
            


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 21:29

    The sticky doesn't work inside element with overflow: hidden or auto. Refer to this https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky

    A workaround can be working with this library

提交回复
热议问题