Click to See Complete Forum and Search --> : Nesting div layers - tweet tweet


changintimes
02-16-2007, 03:08 PM
well........

div 2 is nesting (quite happilly) within div 1,

using relative positioning, how do i get div 2 to center within div 1 ?

toicontien
02-16-2007, 03:18 PM
You don't need relative positioning. You can keep relative positioning, but don't bother setting the left property too. All the inner DIV needs is a width, and then apply margin: auto; to it. Or margin: 0 auto; Auto left and right margins center block elements within other block elements.

changintimes
02-16-2007, 05:19 PM
thanks alot toicontien,

what about top and bottom margins, vertical alignment ?

some of my images are 190px and some 215px, and i want all of them to center v and h within the div,

Centauri
02-16-2007, 10:15 PM
If the div height is fixed, at say 215px, then you could apply the image as a background, and use background-position: center center;

Cheers
Graeme