align = "center" is no longer relevant, but what gave in replacement? How to align the page in the center? margin: 0 auto; does not give a result. You can margin: 0 (number) px; this is real only if you know the display resolution and the width of the page.

margin: 0 (display resolution - page width) px; But how to find out the display resolution and page width? And how to cram it into a margin (there you can enter only 1 number, not an expression).

I have everything in 1 big diva with main ID,

main{ position: absolute; margin: 0 10px; top: 0px; width: 1240px; height: 1600px; z-index: 1; text-align: left; } 

display resolution - 1280x1024 page width - 1240 => so that the page was in my center (1280-1240) / 2 = 10 => margin: 0 10px;

  • Give full page code and css - ViruSkin
  • I have everything in 1 big diva with the ID main, main {position: absolute; margin: 0 10px; top: 0px; width: 1240px; height: 1600px; z-index: 1; text-align: left; } - Sirius

2 answers 2

In addition to the answer @Zhukov Roman ...

If you want the element to be with position: absolute, then use this option:

 main{ position: absolute; width: 1240px; height: 1600px; top: 0; left: 50%; margin-left: -620px; z-index: 1; text-align: left; } 

Do not forget to put " . " Or id in front of the main one, depending on which selector you have.

Good luck

  • Thanks, all worked well. - Sirius
  • @ Oleg24, good luck - Astor

Of course will not be aligned with the margin: 0 auto; because you specified position: absolute;

 main{ position: relative; margin: 0 auto; width: 1240px; height: 1600px; }