PDA

View Full Version : Center Image



today
11-08-2008, 11:04 AM
How would i center a image in the middle of the page in CSS?

All help shall get sexy rep ;]

iTech
11-08-2008, 11:05 AM
Margin: Auto;

today
11-08-2008, 11:06 AM
Margin: Auto;
Would that align it in the middle of the page, equal margins top,bottom,left and right?

iTech
11-08-2008, 11:07 AM
Would that align it in the middle of the page, equal margins top,bottom,left and right?

Should shove it in the middle.
Margins are left & right, I do believe. :)

--ss--
11-08-2008, 12:04 PM
Would that align it in the middle of the page, equal margins top,bottom,left and right?
You can't do exact horizontal center alignment with CSS, you'll have to use JS for that ;).
But for vertical alignment to the centre of the page margin: auto; should work ;).

today
11-08-2008, 12:06 PM
You can't do exact horizontal center alignment with CSS, you'll have to use JS for that ;).
But for vertical alignment to the centre of the page margin: auto; should work ;).
Would it be valid doing so?

Agnostic Bear
11-08-2008, 01:39 PM
You can't do exact horizontal center alignment with CSS, you'll have to use JS for that ;).
But for vertical alignment to the centre of the page margin: auto; should work ;).

Yes you can:

fix the width (i.e 90% or whatever)

then "margin: 0 auto;" will fix it to the exact horizontal centre of the page.

Just put the image in the div and it'll align itself inside the div (the div will move to the centre and the image will go with it)

Decode
11-08-2008, 04:43 PM
margin-left: auto;
margin-right: auto;
text-align: left;

That should work :)

Invent
11-08-2008, 04:44 PM
View the code at pixstudios.net, that has vertical & horizontal centering.

Want to hide these adverts? Register an account for free!