scrollbar on browser and div margin 0 auto jumping

后端 未结 4 1539
逝去的感伤
逝去的感伤 2020-12-30 04:07

i am using div#wrapper margin: 0 auto to center the div, there is scroll bar on this page however when it transition to second page where there is no scroll bar

4条回答
  •  一个人的身影
    2020-12-30 04:54

    If you don't want to force a Y scroll-bar on every page, you can calculate the margins using view-port width. This stopped the auto jumping for me.

    @media (min-width: 960px) {
        .container {
            margin-left: calc(50vw - 480px);
            width: 960px;
        }
    }
    

提交回复
热议问题