css: float image to the left - problem
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
div {
overflow: hidden; /* except IE6 */
display: inline-block; /* IE6 */
}
div {
display: block; /* IE6 */
}
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>
<div style="overflow:auto"> </div>
精彩评论