right-aligned img in a div

N

Nick Howes

Hi,
I've got a div, and in it is some text, and at the start there's an img
which is aligned left so the text wraps around it and works fine in IE. But
in Mozilla and Konqueror, as long as there's enough text it's ok, but if
there's not enough text the div ends up shorter than the image, and the
bottom of the div has a border so that crosses the image. Is there a way to
make the div at least as high as the image, would it help using float:right
instead of using html align?

ta
 
D

David Dorward

Nick said:
Hi,
I've got a div, and in it is some text, and at the start there's an img
which is aligned left so the text wraps around it and works fine in IE.

IE is brokenm
But in Mozilla and Konqueror, as long as there's enough text it's ok, but
if there's not enough text the div ends up shorter than the image, and the
bottom of the div has a border so that crosses the image.

This is normal.
Is there a way to make the div at least as high as the image
http://www.complexspiral.com/publications/containing-floats/

would it help using float:right instead of using html align?

The align attribute is deprecated, you chould be using CSS anyway.
 
T

Toby A Inkster

Nick said:
I've got a div, and in it is some text, and at the start there's an img
which is aligned left so the text wraps around it and works fine in IE. But
in Mozilla and Konqueror, as long as there's enough text it's ok, but if
there's not enough text the div ends up shorter than the image, and the
bottom of the div has a border so that crosses the image.

Moz and Konq are right. If you want to avoid that behaviour, do something
like:

<div style="border: 1px solid black">
<img style="float:left;" alt="alt" src="src" height="h" width="w">
<p>Your text is here.</p>
<div style="clear:both;"><!-- trick div --></div>
</div>
 
N

Nick Howes

David Dorward said:
Help you write better code? Yes.
Help fix the problem you are experiencing? Probably not.

I found a link on your site to an article explaining how this precise
problem can be resolved. I appreciate that CSS is the way forward and I aim
to use it where possible, but at the same time it wouldn't have been so hard
to point me toward the article, or to mention that the link existed.
Thank you anyway for providing the link.
 
D

David Dorward

Nick said:
I found a link on your site to an article explaining how this precise
problem can be resolved. I appreciate that CSS is the way forward and I
aim to use it where possible, but at the same time it wouldn't have been
so hard to point me toward the article, or to mention that the link
existed.

What link? This one:
http://www.complexspiral.com/publications/containing-floats/ ?

I mentioned it in my intial response to your question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top