CSS Fixed position with Auto Margin

后端 未结 3 1050
感动是毒
感动是毒 2020-12-05 14:00

I want a component that keeps horizontal center of the page (two-columns), and I have a sub-component (right column) that I want its position to be fixed, so the sub-compone

3条回答
  •  庸人自扰
    2020-12-05 14:54

    I like to use a wrapper as asolution for this problem:

    .wrapper {
      position: fixed;
      width: 100%;
      top: 0px;
    }
    .wrapper .right {
      width: 500px;
      margin: auto;
    }
    

提交回复
热议问题