views:

107

answers:

1

I have a text block with an image floated left. The images can be of variable width. If the image is say greater than 2/3 the width of the block I want the text to drop down below the image but if not I want it beside the image.

All of this is in Drupal if that matters.

+1  A: 

I'd think you could put the text in a div with float:left . . . and make the width of the div be 1/3 the width of the containing block. That way you could be sure you wouldn't have an image of > 2/3 the width of the block next to it.

Tim Goodman
Of course, then the text won't wrap *around* your image, it will just appear next to it in a block if there's room, and below it otherwise. But it sounds like that's what you want.
Tim Goodman
Yes but if the image is less than 2/3 width then the text is only going to be 1/3 width and of course, as you say it won't wrap around.
Peter Kelley
Yes, perhaps it'd be better to set the `min-width` of the text block to 1/3, so that it could be larger than that but no smaller. However, if you don't want the text in its own block but rather wrapping around the image, then I can't think of a way to do it with pure CSS ... however you could use JavaScript to get the width of the image, and reposition things accordingly.
Tim Goodman