0

I'm trying for the life of me to figure out what should be an excruciatingly simple CSS task: aligning a block of text to the right of an image and vertically positioning the block so it aligns with the bottom of the image; and I'd prefer to not have to declare a height for the containing element as this is for a lengthy image listing and the dimensions will vary (but all with a certain max width/height). I've attempted to define a parent element with "position:relative" containing two left-floated divs, one with the image and the other with the text block, positioned "absolute" and "bottom:0" and I can't seem to get the text block to align with the bottom of the image...

any assistance here may very well help me stave off a fit of insanity ;)

3
  • do u have to use css only or is javascript ok to? Commented May 6, 2011 at 21:57
  • text will be over the image or to the right of it ? Commented May 6, 2011 at 22:00
  • a picture of what you're hoping to obtain would be very helpful. Commented May 6, 2011 at 22:03

1 Answer 1

5

If the text go to the right of the image, just use an element with display:inline-block after the image, and enclose everything in a block (like div). See it here

Sign up to request clarification or add additional context in comments.

14 Comments

Wow - props for figuring out what he was talking about! :)
Dave.. i haven't.. just a wild guess ;)
The vertical-align in your example does nothing. This is the standard location for text <> inline blocks. vertical-align only works in tables. See phrogz.net/css/vertical-align/index.html
@Rudie 'tis not true, vertical align works well with inline-blocks too.. see this fiddle you can change the vertical alignment to middle or top and the text will move accordingly
@nickpish you have to set display:inline-block . updated my code jsfiddle.net/X4CeC
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.