views:

88

answers:

3

i'm trying to do something like:

--------------------------------------------
| --------- text text text text text text  |
| | image | text text text text text text  |
| |       | text text text text text text  |
| |       | text text text text text text  |
| --------- text text text text text text  |
| text text text text text text text text  |
| text text text text text text text text  |
--------------------------------------------

the markup should be right:

<div>
    <img src='myimage.jpg' style='float:left;'>
    tex text text ..
</div>

the problem is - if there's only a few text, the image will "float out" from the container div, which looks like this:

--------------------------------------------
| --------- text text text text text text  |
| | image | text text text text text text  |
|_|       |________________________________|
  |       |
  ---------

any ideas to fix this? the only solution to me seems setting the div container's min-height. thx

+2  A: 
div {
    overflow: hidden;  /* except IE6 */
    display: inline-block; /* IE6 */
}
div {
    display: block; /* IE6 */
}
Ionuț G. Stan
nice! thanks a lot!
Fuxi
+2  A: 

add an empty element at the end of the div element with style="clear:both;, just like this:

<div>
    <img src='myimage.jpg' style='float:left;'>
    tex text text ..
    <div style="clear:both;"></div>
</div>
jigfox
This is a valid solution as well, though it complicates the markup. I have run into cases where the overflow trick doesn't suit my needs, and a `div` with `clear: both` is necessary.
Ryan Kinal
A: 

<div style="overflow:auto"> </div>

Deepak