Sticky top div with absolute positioning

后端 未结 6 1527
温柔的废话
温柔的废话 2020-12-30 00:48

I\'m using absolute positioning to have a div fill up the entire browser window. However, I wan\'t to combine this with a sticky div that sometimes is there and sometimes no

6条回答
  •  春和景丽
    2020-12-30 01:17

    2018-6-18

    I choose the CSS way with position: sticky.

    that https://github.com/abouolia/sticky-sidebar .
    doesn't work for me (I am using Vue.js 2.0 SPA with vue-router & vuex)

    I also want the element position: absolute first,
    and then position: sticky

    Solution

    1. parent HTML element use position: absolute to have the right position.

    (don't forget to set height for parent. for example height:100%)

    1. child HTML element position: sticky

    work for me.

提交回复
热议问题