Fixed position but relative to container

后端 未结 25 1606
独厮守ぢ
独厮守ぢ 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:23

    I have the same issue, one of our team members gives me a solution. To allowed the div fix position and relative to other div, our solution is to use a father container wrap the fix div and scroll div.

    css

    .container {
      position: relative;
      flex:1;
      display:flex;
    }
    
    .fix {
      prosition:absolute;
    }
    

提交回复
热议问题