|
Posted by David Graham on 01/13/06 19:10
"Els" <els.aNOSPAM@tiscali.nl> wrote in message
news:1j0uq2y9w1abl$.15vbx9ayw3s4w$.dlg@40tude.net...
> David Graham wrote:
>
> >> Yup. Default for td's content (whether image or text) is left and
> >> middle aligned, while you can't vertically center content in a div
> >> other than by setting explicit top and bottom margins or using
> >> position:absolute with explicit negative margins.
> >>
> > Understood you until you mentioned a need for 'explicit negative
margins' -
> > not sure what that is for - could you put it into simple terms for a
> > learner - thanks again.
>
> By explicit I meant stipulated in pixels.
> You could give the containing div a fixed height, then position the
> image absolute on left:50% and top:50%, but that would be the position
> of the top left corner of the image, so then you set a negative top
> margin of height/2, and a negative left margin of width/2.
>
> Say your div is 200px high and 200px wide, and your image 150px high
> and 80px wide, you would use CSS like this:
>
> div{
> position:relative;
> height:200px;
> width:200px;
> }
> div img{
> position:absolute;
> top:50%;
> left:50%;
> margin-top:-75px;
> margin-left:-40px;
> }
>
> Meaning you still need to know the measures of the image, while with
> TDs, you don't.
>
> --
> Els http://locusmeus.com/
> Sonhos vem. Sonhos vγo. O resto ι imperfeito.
> - Renato Russo -
Thanks, I see now that a negative margin just shifts the element in the
opposite direction to that which a positive margin normally does.
--
David Graham
[Back to original message]
|