如果包含图像,Div的大小不正确 [英] Div not sized correctly if containing image

查看:59
本文介绍了如果包含图像,Div的大小不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有一个主div,其中包含一些文字和一个img,它是

浮动到右边,导致图像放在div的右边用

左边的文字。但是div的高度大小适合文本

而不是图像。我希望div的高度适合

图像的高度。

搜索谷歌后我发现了一个建议添加

< ; div style =" clear:right">< / div>在包含div的底部只是

结束前< / div>


这似乎工作正常ie(尽管它搞砸了左边由于某种原因,包含div的

的边距)但是在mozilla1.4 / netscape 7.1中它没有任何效果。


我还有其他技术吗?


问候


Tony


解决方案

在文章< bl ************ @ ID-170918.news.uni-berlin.de>中,

" Tony Benham" <到*** @ kerrisway.freeserve.co.uk>写道:

我在一个页面上有一个主div,其中包含一些文本加上一个向右浮动的img,导致图像被放置在div的右侧
左边的文字。然而,div的高度大小适合文本
而不是图像。我希望div的高度适合
图像的高度。
搜索谷歌后我发现了一个建议添加
< div style =" clear:right"> < / DIV>在结束之前只包含div的底部< / div>

这似乎在ie中工作正常(虽然它搞砸了包含
的左边距div由于某种原因)但是在mozilla1.4 / netscape 7.1中它没有任何效果。

我可以使用另一种技术吗?




我经常使用< br class =" break">

..break {clear:both; }


当然真正的方法是:

img {float:right; }

img:在{clear:right;之后}


但MSIE不支持:伪后选择器。


-

Kris
kr*******@xs4all.neth erlands(nl)


Tony Benham写道:

我在页面上有一个主div,其中包含一些文本和一个向右浮动的img,导致图像被放置在div的右边,左边是文本。然而,div的高度大小适合文本
而不是图像。


这是正确的行为。

我希望div的高度适合
图像的高度。
搜索谷歌后,我发现了一个建议添加
< div style =" clear:right">< / div>在结束之前只包含div的底部< / div>

这似乎在ie中工作正常(虽然它搞砸了包含
的左边距div由于某种原因)但在mozilla1.4 / netscape 7.1中它没有任何影响。




这应该有效;事实上,我在Mozilla中成功使用它

1.3 / win2k。


检查你的html和css是否有错误。然后,提供一个网址。


-

Brian

按照我地址中的说明给我发电子邮件


" Brian" <我们***** @ mangymutt.com.invalid-除去-这部分>在消息中写道

news:hBCeb.474768


I have a main div on a page that contains some text plus an img which is
floated right, causing the image to be placed on the right of the div with
the text on the left. However the height of the div sizes to fit the text
but not the image. I want the div to size in height to fit the height of the
image.
After searching google I found a suggestion to add
<div style="clear:right"></div> at the bottom of the containing div just
before the ending </div>

This seems to work ok in ie (although it screws up the left margin of the
containing div for some reason) but in mozilla1.4/netscape 7.1 it doesn''t
have any effect.

Is there another technique I could use ?

Regards

Tony


解决方案

In article <bl************@ID-170918.news.uni-berlin.de>,
"Tony Benham" <to***@kerrisway.freeserve.co.uk> wrote:

I have a main div on a page that contains some text plus an img which is
floated right, causing the image to be placed on the right of the div with
the text on the left. However the height of the div sizes to fit the text
but not the image. I want the div to size in height to fit the height of the
image.
After searching google I found a suggestion to add
<div style="clear:right"></div> at the bottom of the containing div just
before the ending </div>

This seems to work ok in ie (although it screws up the left margin of the
containing div for some reason) but in mozilla1.4/netscape 7.1 it doesn''t
have any effect.

Is there another technique I could use ?



I often use <br class="break">
..break { clear: both; }

The real method of course is:
img { float: right; }
img:after { clear: right; }

But MSIE does not support the :after pseudo-selector.

--
Kris
kr*******@xs4all.netherlands (nl)


Tony Benham wrote:

I have a main div on a page that contains some text plus an img which is
floated right, causing the image to be placed on the right of the div with
the text on the left. However the height of the div sizes to fit the text
but not the image.
That''s correct behavior.
I want the div to size in height to fit the height of the
image.
After searching google I found a suggestion to add
<div style="clear:right"></div> at the bottom of the containing div just
before the ending </div>

This seems to work ok in ie (although it screws up the left margin of the
containing div for some reason) but in mozilla1.4/netscape 7.1 it doesn''t
have any effect.



That should work; in fact, I have used it with success in Mozilla
1.3/win2k.

Check your html and css for errors. Then, supply a url.

--
Brian
follow the directions in my address to email me


"Brian" <us*****@mangymutt.com.invalid-remove-this-part> wrote in message
news:hBCeb.474768


这篇关于如果包含图像,Div的大小不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆