本文介绍了在Firefox中清除浮动的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨组,


我在清除浮动的div时遇到了一些问题。我常用的方法在Konqueror中运行正常,但在Firefox中没有。以下是一个例子:


< html>< body>


< div id =''left''风格= '' 浮动:左; border:1px solid red;''> Flolated left< / div>


< div id =''right''style =''float:right; border:1px solid blue;''> Floated right< / div>


< div id =''clear''style =''clear:both;高度:0像素;溢出:隐藏;''>& nbsp;< / div>


< div id =''其他''style =''margin-top:20px; border:1px solid green;''>这应该是左下方的20px< / div>


< / body>< / html>


我正试图让clear-div清除所有浮点数,而不是实际渲染。但Firefox显然认为高度== 0的div对文档不应该有任何影响。


如何解决这个问题?我怎么能这样做?

谢谢,

Niels

Hi group,

I have some problems with clearing floated divs. My usual method works fine in Konqueror, but not in Firefox. Here''s an example:

<html><body>

<div id=''left'' style=''float:left; border:1px solid red;''>Floated left</div>

<div id=''right'' style=''float:right; border:1px solid blue;''>Floated right</div>

<div id=''clear'' style=''clear:both; height:0px; overflow:hidden;''>&nbsp;</div>

<div id=''other'' style=''margin-top:20px; border:1px solid green;''>This should be 20px beneath Left and Right</div>

</body></html>

I''m trying to get the clear-div to clear all floats, without actually being rendered. But Firefox apparently thinks a div with height==0 shouldn''t have any influence at all on the document.

How can I solve this problem? How else can I do this?
Thanks,
Niels

推荐答案




为什么不给它1px高度?

如果你设置边距为0,我相信没有人会注意到div的存在。


-

Els


Sonhos vem。 Sonhos v?o。 Orestoébritfeito。

- Renato Russo -



Why don''t you give it 1px height?
If you set the margins to 0, I''m sure no one will notice the
existence of the div.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos v?o. O resto é imperfeito.
- Renato Russo -




我会。我想我可以忍受它,我想我已经在其他地方用它来解决问题了。但我觉得这是一个黑客攻击,而且我不会理解为什么Firefox显然会出现这样的错误行为。


想想看,最近我曾经遇到过几种情况,其中Firefox是一个非常聪明的物品。

非常感谢,

Niels


I would. I suppose I could live with it, and I think I''ve done it before
somewhere else to solve the problem. But I feel it''s a hack, and I don''t
understand why Firefox apparently misbehaves like this.

Come to think of it, lately I''ve had several situations where Firefox was a
little too clever for it''s own good.
Thanks though,
Niels





因为它是一个高度。

身高:0;不是一个高度。我发现

浏览器忽略没有任何音量的任何内容都是合乎逻辑的。

(当蓝线长度为零时你看到什么颜色?)


不说这是正确的行为 - 我没有检查规格

就可以了。无论如何,即使它是正确的行为,

其他浏览器的行为也不同。



Because it''s a height.
height:0; is not a height. I find it quite logical for a
browser to ignore the presence of anything without any volume.
(what colour do you see when a blue line has zero length?)

Not saying it''s proper behaviour - I haven''t checked the specs
on it. Doesn''t matter though, even if it''s proper behaviour,
the other browsers are acting differently anyway.



我愿意。我想我可以忍受它,我想我已经在其他地方做过它来解决这个问题。但我觉得这是一个黑客攻击,我不明白为什么Firefox显然行为不端。



I would. I suppose I could live with it, and I think I''ve
done it before somewhere else to solve the problem. But I
feel it''s a hack, and I don''t understand why Firefox
apparently misbehaves like this.




另一种方式是当然要明确:两者;物业到

下一个元素,没有使用单独的div。

想想看,最近我有几种情况
其中Firefox有点太聪明了,因为它本身就是好事。



Another way is of course to set the clear:both; property to
the next element, without using a seperate div for it.
Come to think of it, lately I''ve had several situations
where Firefox was a little too clever for it''s own good.




< g>

而且每个人都变得越来越聪明版。 Firefox 0.9是第一个正确居中页面的Gecko,而不需要

黑客让它留在窗口内。 Firefox 0.8仍然需要hack。

(参见)

-

Els


Sonhos vem。 Sonhos v?o。 Orestoébritfeito。

- Renato Russo -



<g>
And it''s getting cleverer with each version. Firefox 0.9 is
the first Gecko to center a page properly without needing
hacks to make it stay inside the window. Firefox 0.8 still
needed the hack.
(see http://locusmeus.com/html-css/pageslipping.html )
--
Els
http://locusmeus.com/
Sonhos vem. Sonhos v?o. O resto é imperfeito.
- Renato Russo -


这篇关于在Firefox中清除浮动的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 17:40