漂浮,这是他们漂浮到多高的问题 [英] Floats, a problem with how high they float up to

查看:79
本文介绍了漂浮,这是他们漂浮到多高的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://digitalrat.co.uk/test/index.html


我在div之前将div放在体内,并设置了上边距。我希望
预计浮动上升到身体的顶部,而是在Firefox&

Opera中它的顶部不会超过下面div的顶部边界(在IE中

确实会出现问题。)


这是正确的行为吗?


除非我'我错过了什么,这似乎是一个CSS的案例

指定浮点数应该尽可能高,没有明确

定义这意味着什么(Eric Meyer发出警告关于这个关于p284
CSS第二版的修改指南的b $ b。


我是错误的,浏览器还是CSS规范?


BTW我可以通过将间距放在身体填充上来解决这个问题&

删除第二个div的边距;我只想了解发生了什么。


干杯,


-

Michael

mrozatukgatewaydotne t

http://digitalrat.co.uk/test/index.html

I float a div left in body prior to a div with top margin set. I
expected the float to rise to the top of body, but instead in Firefox &
Opera its top won''t go above the top border of the following div (In IE
it does go right up).

Is this correct behaviour?

Unless I''m missing something, this appears to be a case of CSS
specifying floats should go as high as possible, without clearly
defining what this means (Eric Meyer gives a warning about this on p284
of 2nd ed of CSS The Def Guide).

Am I in error, the browsers or the CSS spec?

BTW I can workaround this by putting the spacing onto body padding &
removing the 2nd div''s margin; I just wanted to understand what''s going on.

Cheers,

--
Michael
m r o z a t u k g a t e w a y d o t n e t

推荐答案

Michael Rozdoba< mr ** @ nowhere.invalid>写道:
Michael Rozdoba <mr**@nowhere.invalid> wrote:
http:// digitalrat.co.uk/test/index.html

我在div之前将div放在体内,并设置了上边距。我希望浮动升到身体的顶部,但是在Firefox&
Opera中它的顶部不会超过下面div的顶部边界(在IE中它/它确实是这样的。

这是正确的行为吗?

除非我遗漏了什么,这似乎是CSS的情况
指定浮点数应该尽可能高,没有明确界定这意味着什么(Eric Meyer在CSS第2版的版本指南中对此进行了警告)。

我是错误,浏览器或CSS规范?
BTW我可以解决这个问题,方法是将空格放在身体填充上,然后移除第二个div的边距;我只想了解发生了什么。
http://digitalrat.co.uk/test/index.html

I float a div left in body prior to a div with top margin set. I
expected the float to rise to the top of body, but instead in Firefox &
Opera its top won''t go above the top border of the following div (In IE
it does go right up).

Is this correct behaviour?

Unless I''m missing something, this appears to be a case of CSS
specifying floats should go as high as possible, without clearly
defining what this means (Eric Meyer gives a warning about this on p284
of 2nd ed of CSS The Def Guide).

Am I in error, the browsers or the CSS spec?

BTW I can workaround this by putting the spacing onto body padding &
removing the 2nd div''s margin; I just wanted to understand what''s going on.




你所看到的是利润率下降,例如:在

上设置1px填充,正文将防止边距崩溃。


-

Spartanicus



What you are seeing is collapsing margins, e.g. setting a 1px padding on
the body will prevent the margins from collapsing.

--
Spartanicus


Spartanicus写道:
Spartanicus wrote:
你所看到的是边缘崩溃,例如在身体上设置1px填充物将防止边缘坍塌。
What you are seeing is collapsing margins, e.g. setting a 1px padding on
the body will prevent the margins from collapsing.




不确定我是否遵循;可能是我的错误。


浮动的div&容器上没有填充

(正文),所以我希望div升到顶部。除了Firefox之外

&歌剧它不会 - 它只会跟随静态

div的边界一样高(它故意位于较低的顶部

边距)。


-

Michael

mrozatukgatewaydotne t



Not sure I follow; probably my error.

There''s no margin on the floated div & no padding on the container
(body), so I would expect the div to rise to the top. Except in Firefox
& Opera it doesn''t - it only gets as high as the border of the static
div which follows it (that intentionally is positioned lower with a top
margin).

--
Michael
m r o z a t u k g a t e w a y d o t n e t


Michael Rozdoba< ;先生** @ nowhere.invalid>写道:
Michael Rozdoba <mr**@nowhere.invalid> writes:
Spartanicus写道:
Spartanicus wrote:
你所看到的是边缘崩溃,例如:在身体上设置1px填充物将防止边缘坍塌。
What you are seeing is collapsing margins, e.g. setting a 1px padding on
the body will prevent the margins from collapsing.



不确定我是否遵循;可能是我的错误。

浮动的div&
容器(主体)上没有填充,所以我希望div上升到
顶部。



Not sure I follow; probably my error.

There''s no margin on the floated div & no padding on the
container (body), so I would expect the div to rise to the
top.




我不会。暂时忽略这些定义,通常需要一个浮动项目的是它看起来好像接近文本中出现在
来源。例如,如果你有一张图片说明

一个想法提到了一个很长的dia骂,你会想要浮动出现在左边(或右边)接近

的想法,不要一直浮到页面顶部。


CSS21中的非正式描述支持这个视图(9.5):


浮动框向左或向右移动,直到它的外边缘接触到包含块边缘或外部

边缘另一个浮子。如果有一个线盒,

的顶部浮动框与当前

线框的顶部对齐。


请注意,它指的是一个不包含块的线框。

再次,在9.5.1


6元素的外部顶部'浮动框可能不比包含框的任何行框的顶部高出b

来源于源文档中较早的元素。


我认为9.5.1中的后续文本会引起混淆:


8浮动框必须尽可能高。


,因为它没有明确说出......与6

以上一致,但我确定'这是'的意图。


-
$ b $bJónFairbairn Jo *********** @ cl.cam.ac.uk



I wouldn''t. Ignoring the definitions for a moment, what one
would generally want of a floating item is that it appears
close to the point in the text where it appears in the
source. For example, if you have a picture that illustrates
an idea mentioned half way down a long diatribe, you would
want the float to appear at the left (or right) close to the
idea, not float all the way to the top of the page.

The informal description in CSS21 supports this view (9.5):

A floated box is shifted to the left or right until its
outer edge touches the containing block edge or the outer
edge of another float. If there''s a line box, the top of
the floated box is aligned with the top of the current
line box.

Note that it refers to a line box, not containing block.
Again, in 9.5.1

6 The outer top of an element''s floating box may not be
higher than the top of any line-box containing a box
generated by an element earlier in the source document.

I think the later text in 9.5.1 causes the confusion:

8 A floating box must be placed as high as possible.

because it doesn''t explicitly say "... consistent with 6
above", but I''m sure that''s what''s intended.

--
Jón Fairbairn Jo***********@cl.cam.ac.uk


这篇关于漂浮,这是他们漂浮到多高的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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