How to center a wrapper-div and not the content

前端 未结 3 1777
半阙折子戏
半阙折子戏 2021-02-06 11:33

I want my page to always be centered in the browser without affecting the content( like align-text: center; does). I want to center my wrapper-div.. How do I do this?

Si

相关标签:
3条回答
  • 2021-02-06 11:55

    you can set the margin property for the wrapper div like following in CSS

    #wrapper { margin:20px auto } 
    
    0 讨论(0)
  • 2021-02-06 12:09
     #wrapper {
         width: ...
         margin: 0 auto;
     }
    

    no need to set text-align

    0 讨论(0)
  • 2021-02-06 12:10

    Set your style something like for the wrapper div.

    #wrapper {
    
    width: 841px;
    margin: 0 auto;
    

    }

    In this way the wrapper div will always be centered according to your screen width. I hope it helps.

    0 讨论(0)
提交回复
热议问题