Hello,
I want to center a div container on a page, in the css I am using
margin-left:auto;
does not seem to work.
Anything goes hereThanks
Hello,
I want to center a div container on a page, in the css I am using
margin-left:auto;
does not seem to work.
Anything goes hereThanks
This should work:
margin:0px auto;
Or you can even try this if you want:
margin:auto;
position:relative;
width: 600px; /* or whatever width */
You can center a div horizontally with:
margin: 0 auto;
There's no need for the addition of "px" when you set it to 0.
But: this doesn't work unless you set a width
for the div.
So the complete CSS for this would be for example:
width: 500px;
margin: 0 auto;
This creates a 500px width div, centered horizontally in it's container.