浮动/位置:div和span之间的任何差异? [英] float/position: any difference between div and span?

查看:96
本文介绍了浮动/位置:div和span之间的任何差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑浮动跨度而不是漂浮div,

和绝对定位相同。什么是浮动或

定位是一小段文本,我看不出两者之间的任何_visual_

差异。


我想要做的是将一个修订日期浮动(或定位)在

的右边缘,该边缘也有一些左对齐的文字。我之前尝试过
这样做并且在MSIE 4中完全失败了。但是我使用span而不是div,并且最近碰到了

http://www.blooberry.com/indexdot/ cs ... sify / float.htm
http://www.blooberry.com/indexdot/cs...y/position.htm



我看到MSIE4不知道使用这些

属性来处理内联元素。


我当然理解包含其他块的东西需要

才能成为div,但如果它只是文本是否重要?


-

Stan Brown,Oak Road Systems,Cortland County,New York,USA
http://OakRoadSystems.com/

HT ML 4.01规范: http://www.w3.org/TR/html401/

验证人: http://validator.w3.org/

CSS 2规范: http ://www.w3.org/TR/REC-CSS2/

2.1更改: http://www.w3.org/TR/CSS21/changes.html

验证者: http://jigsaw.w3.org/css-validator/

解决方案

Stan Brown写道:

我一直在考虑浮动一个跨度而不是浮动一个div,
和绝对定位相同。当浮动或定位的文本是一小段文本时,我看不出两者之间的任何_visual_
差异。

我想做的是浮动(或位置)在一行的右边缘处的修订日期,该行也有一些文本左对齐。我之前尝试过这样做并在MSIE 4中彻底失败。但是我使用span而不是div,并且最近遇到了

http://www.blooberry.com/indexdot/cs ... sify / float.htm



http://www.blooberry.com/indexdot/cs...y/position.htm


我知道MSIE4不适用于具有这些
属性的内联元素。

我当然理解包含其他块的内容需要
成为一个div,但如果它只是文本是否重要?




据我所知< div>是一个块元素,< span>是内联

元素。一个人不应该浮动内联元素,因为它们应该是内容。

说完这个,我知道有些浏览器不会'' t抗议内联

元素被视为块元素。当你发现时,

他们按照你想要的方式呈现内容。


但请记住,这是不正确的。所有浏览器(我在这里做梦)都会按照指定处理标记

和样式。这意味着你必须全力以赴地查找当时发生故障的源代码。


我想,这取决于你。


-


Groet,

芭芭拉

http://home.wanadoo.nl/b.de.zoete/html /vliegen.html * Zweefvliegen *?
http://home.wanadoo.nl/b.de.zoete/html/weblog.html * Dagboek *


斯坦布朗写道:

我一直在考虑浮动跨度与漂浮div,
和绝对定位相同。当浮动或定位的文本是一小段文本时,我看不出两者之间的任何_visual_
差异。

我想做的是浮动(或位置)在一行的右边缘处的修订日期,该行也有一些文本左对齐。我之前尝试过这样做并在MSIE 4中彻底失败。但是我使用span而不是div,并且最近遇到了

http://www.blooberry.com/indexdot/cs ... sify / float.htm



http://www.blooberry.com/indexdot/cs...y/position.htm


我知道MSIE4不适用于具有这些
属性的内联元素。

我当然理解包含其他块的内容需要
成为一个div,但如果它只是文本是否重要?




据我所知< div>是一个块元素,< span>是内联

元素。一个人不应该浮动内联元素,因为它们应该是内容。

说完这个,我知道有些浏览器不会'' t抗议内联

元素被视为块元素。当你发现时,

他们按照你想要的方式呈现内容。


但请记住,这是不正确的。所有浏览器(我在这里做梦)都会按照指定处理标记

和样式。这意味着你必须全力以赴地查找当时发生故障的源代码。


我想,这取决于你。


-


Groet,

芭芭拉

http://home.wanadoo.nl/b.de.zoete/html /vliegen.html * Zweefvliegen *?
http://home.wanadoo.nl/b.de.zoete/html/weblog.html * Dagboek *


Barbara de Zoete写道:


据我所知< div>是一个块元素,< span>是一个内联
元素。一个不应该浮动内联元素,因为它们应该是(ahum
...)内联。




处理内联元素没有任何内在错误as

块元素,或反之。如果它确实是一个坏主意,那么

" display"属性可能根本不存在。


什么人不应该做_markup_元素作为内联(span)当它

应该是块(div) )首先。 ;)


-

要通过电子邮件发送回复,请删除(破折号)ns(短划线)。邮件发送到ns

地址会被自动删除,不会被读取。


I''ve been thinking about float-ing a span versus float-ing a div,
and the same for absolute positioning. When what is floated or
positioned is a short chunk of text, I don''t see any _visual_
difference between the two.

What I want to do is float (or position) a revision date at the
right margin of a line that also has some text left justified. I
tried earlier to do this and failed utterly in MSIE 4. But I was
using span not div, and having recently come across

http://www.blooberry.com/indexdot/cs...sify/float.htm and http://www.blooberry.com/indexdot/cs...y/position.htm


I see that MSIE4 is known not to work for inline elements with these
properties.

I understand of course that something containing other blocks needs
to be a div, but if it''s just text does it matter?

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/

解决方案

Stan Brown wrote:

I''ve been thinking about float-ing a span versus float-ing a div,
and the same for absolute positioning. When what is floated or
positioned is a short chunk of text, I don''t see any _visual_
difference between the two.

What I want to do is float (or position) a revision date at the
right margin of a line that also has some text left justified. I
tried earlier to do this and failed utterly in MSIE 4. But I was
using span not div, and having recently come across

http://www.blooberry.com/indexdot/cs...sify/float.htm



and

http://www.blooberry.com/indexdot/cs...y/position.htm



I see that MSIE4 is known not to work for inline elements with these
properties.

I understand of course that something containing other blocks needs
to be a div, but if it''s just text does it matter?



As far as I know <div> is a block element and <span> is an inline
element. One shouldn''t float inline elements, for they should be (ahum
....) inline.
Having said this, I know that some browsers don''t protest against inline
elements being treated as if they were block elements. As you found out,
they render the content the way you want them to.

But keep in mind that it is not correct. There could come a moment in
time (ahum again) that all browsers (me dreaming here) do treat mark-up
and style as specified. This would mean you have to go thrue all your
pages to find the then malfunctioning source code.

It''s up to you, I guess.

--

Groet,
Barbara

http://home.wanadoo.nl/b.de.zoete/html/vliegen.html *Zweefvliegen*?
http://home.wanadoo.nl/b.de.zoete/html/weblog.html *Dagboek*


Stan Brown wrote:

I''ve been thinking about float-ing a span versus float-ing a div,
and the same for absolute positioning. When what is floated or
positioned is a short chunk of text, I don''t see any _visual_
difference between the two.

What I want to do is float (or position) a revision date at the
right margin of a line that also has some text left justified. I
tried earlier to do this and failed utterly in MSIE 4. But I was
using span not div, and having recently come across

http://www.blooberry.com/indexdot/cs...sify/float.htm



and

http://www.blooberry.com/indexdot/cs...y/position.htm



I see that MSIE4 is known not to work for inline elements with these
properties.

I understand of course that something containing other blocks needs
to be a div, but if it''s just text does it matter?



As far as I know <div> is a block element and <span> is an inline
element. One shouldn''t float inline elements, for they should be (ahum
....) inline.
Having said this, I know that some browsers don''t protest against inline
elements being treated as if they were block elements. As you found out,
they render the content the way you want them to.

But keep in mind that it is not correct. There could come a moment in
time (ahum again) that all browsers (me dreaming here) do treat mark-up
and style as specified. This would mean you have to go thrue all your
pages to find the then malfunctioning source code.

It''s up to you, I guess.

--

Groet,
Barbara

http://home.wanadoo.nl/b.de.zoete/html/vliegen.html *Zweefvliegen*?
http://home.wanadoo.nl/b.de.zoete/html/weblog.html *Dagboek*


Barbara de Zoete wrote:


As far as I know <div> is a block element and <span> is an inline
element. One shouldn''t float inline elements, for they should be (ahum
...) inline.



There is nothing inherently wrong about treating inline elements as
block elements, or the reverse. If it really were a bad idea, the
"display" property might not even exist.

What one shouldn''t do is _markup_ an element as inline (span) when it
should have been block (div) in the first place. ;)

--
To email a reply, remove (dash)ns(dash). Mail sent to the ns
address is automatically deleted and will not be read.


这篇关于浮动/位置:div和span之间的任何差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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