How to display the entire page in the center of the browser

I have three divs outside my content site

homepage code:

<div id="content-outer" class="clear">
 <div id="content-wrapper">    
   <div id="content">      
     <asp:ContentPlaceHolder ID = "ContentPlaceHolder1" runat="server" >
      </asp:ContentPlaceHolder>     
   </div>
 </div>
</div>

the width of the outer div is 1400px, it works well on a screen with a width of 1400 or more, but when I launch it in the width of 1024, the whole page starts on the left side, I want to center my page when opening in the browser, I gave some css properties, such as

Content-External: Margin Left: Auto; margin-right: auto; (does not work)

but I can not center the alignment of my entire page, plz tell me how can I do this, I also gave the same properties to the body, but again no luck

+3
source share
2 answers

-, , .

<center>
    Your content here
</center>

( css inline )

<div style="width: 1400px; margin: 0 auto;">
    Your content here
</div>

.

, , . , , .

:

  • - , - .
  • , ( ).
  • -

, .

<div style="width: auto; margin: 0 10%;">
    Your content here
</div>
+7

<body> 
 <div id="divMain"> 
  ... 
 </div> 
</body> 


body 
{ 
 margin: 0; 
 padding: 0; 
 text-align: center; 
} 
#divMain
{ 
 margin: 0 auto; 
 padding: 0; 
 width: 1024px; 
 text-align: left; 
} 



or

.divMain
{
position: absolute;
left: 10%;
width: 80%;
} 
+1

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


All Articles