Jump to content

[SOLVED] align img to bottom of div


ifubad

Recommended Posts

I'll save it for future reference. I need it to also work in IE and prefer not to use hacks. It's only a single page that needs this, I guess I may just have to be deal with using table. Why did Bill Gates named his company after his penis???

 

Thnx anyway

You can set the position on the containing element to relative, then set the position of the element you want to be at the bottom to absolute. Then set the bottom on the absolutely positioned element to zero. If you want, you can also give the containing element a bottom padding that is equal to the height of the absolutely positioned element so that things don't drop behind it (I haven't tested the padding, but it should work).

Ok, using position relative and then absolute to vertically align the image to the bottom of its container was really simple. Now, the other problem is that when an element is set to absolute, it automatically left align itself to its parent container, and to center it horizontally, I need to set the left property?

 

If so, now the tricky part is that if the width of each image is different, is the only way to figure out how many pixels to apply to the left property is using php? (which I already figured out the math to do that with, just trying to see if there was a more efficient way of doing this).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.