How do we center an image dead center? I've read how to do this before, but i can't find the information when i need it.
bill
9:00 am on Dec 20, 2003 (gmt 0)
margin: auto;
DaScribbler
9:01 am on Dec 20, 2003 (gmt 0)
I assume you're talking about Background images...
You can use background-position: 50% 50%; to get it dead center. Optionally you can also declare the X and Y values in actual pixels.
mylungsarempty
6:22 pm on Dec 20, 2003 (gmt 0)
does that margin:auto work in ie? cause i tried it, and it didn't do a thing. I've seen this before though -- it isn't a background image i'm talking about, per se... maybe it is only a javascript script that does this -- in which case i'm in the wrong area of the site.
iamlost
7:10 pm on Dec 20, 2003 (gmt 0)
If it is general centering AND you know the height and width of the object you want to center:
<div> { /* or other element */ left: 50%; top: 50%; margin-top: <-value>; /* where value=1/2*div height */ margin-left: <-value>; /* where value=1/2*div width> */ }
photon
1:39 am on Dec 21, 2003 (gmt 0)
No,
margin:auto
does not wotk in IE.
Farix
2:30 am on Dec 21, 2003 (gmt 0)
It does work in IE6, so long as you have a DOCTYPE that makes it go into strict-mode.