How to center a wrapper div, not content

I want my page to always be centered in the browser without affecting the content (e.g. align-text: center; does). I want to focus on my wrapper div. How can I do it?

Simplified Existing Page:

<div id="wrapper"> <div id="header"> Music Heaven </div> <div id="topmeny"> </div> <div id="menu"> </div> <div id="content"> </div> <div id="bottom"> SiteAdmin </div> </div> 

Whole fiddle: http://jsfiddle.net/EndQb/

+6
source share
3 answers
  #wrapper { width: ... margin: 0 auto; } 

no need to set text alignment

+19
source

Set your style somehow as for a wrapper div.

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

}

This way the wrapper div will always be centered according to the width of the screen. Hope this helps.

+2
source

you can set margin property for div wrapper as shown in CSS

 #wrapper { margin:20px auto } 
+1
source

Source: https://habr.com/ru/post/904901/


All Articles