...

View Full Version : images dont listen to margins



wsammy
09-22-2007, 04:31 PM
have a problem.
I want to center my page and was told to put my margins as {margin-right: auto; margin-left: auto;} I have done this and my text centers in the middle of the page. my images however do not do this.

my css looks like this:

#containertext {
margin-left: auto;
margin-right: auto;
width: 500px;
}

#green {
top: 390;
left: 120;
}

#carbon {
top: 270;
left: 480;
}

#lib {
top: 255;
left: 210;
}

#yougov {
top: 250
}

#iraq {
top: 390;
left: 380;
}

#bodytext {
top: 20;
}

#green, #carbon, #lib, #yougov, #iraq, #header, #bodytext {
position: absolute;
}

and i have put a division with the id of "container" around the whole page.
Does anyone have the answer?

gnomeontherun
09-22-2007, 05:12 PM
Could you post the page code or link to it so we can see how the images are set?

rmedek
09-22-2007, 05:13 PM
Images are inline elements—which don't respond to margins—and so you need to declare them block-level elements first…


img {
display: block;
margin: 0 auto;
}

Hope this helps…

wsammy
09-22-2007, 05:18 PM
Images are inline elements—which don't respond to margins—and so you need to declare them block-level elements first…


img {
display: block;
margin: 0 auto;
}

Hope this helps…

Thanks that was really helpful.:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum