Cross browser div alignment using CSS

Posted by Misha Moroshko on Stack Overflow See other posts from Stack Overflow or by Misha Moroshko
Published on 2010-05-29T14:19:07Z Indexed on 2010/05/29 14:22 UTC
Read the original article Hit count: 297

Filed under:
|
|
|
|

What is the easiest way to align a div whose position is relative horizontally and vertically using CSS ? The width and the height of the div is unknown, i.e. it should work for every div dimension and in all major browsers.

I thought to make the horizontal alignment using:

margin-left: auto;
margin-right: auto;

like I did here.

Is this a good cross browser solution for horizontal alignment ?

How could I do the vertical alignment ?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery