DIV浮动问题...... [英] DIV float question...

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

问题描述

请耐心等待......我是DIV的新手。


为什么以下在IE6中工作,但在NS7中不工作?

Please bear with me ... I am a newbie to DIVs.

Why does the following work in IE6, but not in NS7?

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 3.2 // EN">
< HTML>

< HEAD> < META HTTP-EQUIV =" Content-Type" CONTENT =" text / html的; charset = iso-8859-1">
< TITLE> DIV float示例< / TITLE>
< style type =" text / css">
<! - -
div.floater {float:left}
- >
< / style>

< / HEAD>
< BODY>
< DIV CLASS =" floater">这是一个测试< / DIV>
< DIV CLASS =" floater">快速的棕色狐狸跳了过来懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒惰的狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过了懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过了懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒狗,快速的棕色狐狸跳过懒狗< / DIV>
< / BODY>

< / HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>DIV float Example</TITLE>
<style type="text/css">
<!--
div.floater {float: left}
-->
</style>

</HEAD>

<BODY>
<DIV CLASS="floater">this is a test </DIV>
<DIV CLASS="floater">the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy
dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown
fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the
lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick
brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog</DIV>
</BODY>

</HTML>




我刚开始玩DIV。


-


Dennis



I am just starting to play with DIVs.

--

Dennis

推荐答案

Dennis写道:
Dennis wrote:
请耐心等待......我是DIV的新手。

为什么以下工作在IE6中,但在NS7中没有?
Please bear with me ... I am a newbie to DIVs.

Why does the following work in IE6, but not in NS7?
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 3.2 // EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">



[剪辑代码]

我刚开始玩DIV。


[snip code]
I am just starting to play with DIVs.




好​​的,显然你也开始玩Usenet ;-)


要描述一个问题,请发一个网址,不要指望别人复制

并将你的代码粘贴到文本编辑器中,给它起一个名字,将它上传到他们自己的服务器上,然后查看问题所在。这一点是你的工作。你越容易让别人帮助你,你就会想要帮助你的人越多。


现在,你的问题。您使用的doctype将IE引入Quirks

模式。这基本上意味着它将基本上不遵循其他浏览器所做的

标准。因此,要使IE正确运行

,请改用此doctype:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN"

" http://www.w3.org/TR/html4/strict.dtd">


你会看到, IE现在停止做你想做的事了:-)


现在,要让两个div相互浮动,你需要给它们一个b
宽度。


-

Els http://locusmeus.com/

Sonhos vem。 Sonhos v?£。 O resto ?? crisfeito。

- Renato Russo -



Okay, apparently, you''re also starting to play with Usenet ;-)

To describe a problem, please post a URL, don''t expect people to copy
and paste your code into a text editor, give it a name, upload it to
their own server, and then look what the problem is. That bit is your
work. The easier you make it for other people to help you, the more
people will want to help you.

Now, to your problem. The doctype you used, throws IE into Quirks
mode. This basically means that it will largely not follow the
standards, which the other browsers do. So, to make IE behave
correctly, use this doctype instead:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

You will see, that IE stops doing what you want now too :-)

Now, to have two divs floated next to each other, you need to give
them a width.

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


" Dennis"写道:
"Dennis" wrote:
请耐心等待......我是DIV的新手。

为什么以下在IE6中工作,而在NS7中不工作?
Please bear with me ... I am a newbie to DIVs.

Why does the following work in IE6, but not in NS7?
< style type =" text / css">
<! -
div.floater {float:left}
- - >
< / style>
< DIV CLASS =" floater">这是一个测试< / DIV>
< DIV CLASS =" floater">快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳过懒惰的狗快速的棕色狐狸跳过懒狗快速的棕色狐狸跳了起来
<style type="text/css">
<!--
div.floater {float: left}
-->
</style>
<DIV CLASS="floater">this is a test </DIV>
<DIV CLASS="floater">the quick brown fox jumped over the lazy dog the quick
brown fox jumped over the lazy dog the quick brown fox jumped over the lazy
dog the quick brown fox jumped over the lazy dog the quick brown fox jumped




这里有一个提示:如果你想要一个有用的答案,试着描述(a)你想要的b $ b b发生了,(b)实际发生了什么。简单地说它

不起作用让你无处可去。


你的标记更有可能在NS7中正确呈现,而不是在IE6中,但是然后

我不知道你想要做什么首先。


-

phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/

< br>

2005年9月5日星期一18:51:04 +0200,Els< el ********* @ tiscali.nl>写道:
On Mon, 5 Sep 2005 18:51:04 +0200, Els <el*********@tiscali.nl> wrote:
好吧,显然,你也开始玩Usenet ;-)


不是真的......但是我'已经发布了一份副本(修改后的DOCTYPE):

http://kowallek.myiglou.com/temp/div_float_example.html

因此,要使IE正确运行,请使用此doctype:

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN"
" http://www.w3.org/TR/html4/strict.dtd" ;>
你会看到,IE现在停止做你想做的事情:-)


除非我把它贴错了,否则它似乎没有什么区别。

现在,要让两个div互相浮动,你需要给它们一个宽度。
Okay, apparently, you''re also starting to play with Usenet ;-)
Not really ... but I''ve posted a copy (with your revised DOCTYPE) to:

http://kowallek.myiglou.com/temp/div_float_example.html
So, to make IE behave
correctly, use this doctype instead:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> You will see, that IE stops doing what you want now too :-)
Unless I pasted it in wrong, it doesn''t appear to have made a difference.
Now, to have two divs floated next to each other, you need to give
them a width.




那个毫无疑问,这是我的问题的答案。但是,如果我希望第一列的宽度与它包含的任何文本一样宽?离开

IE中的宽度似乎有用......但不适用于NS。


如果你愿意,请随意给我一个很好的教程。


PS我想要做的是重写一个生成HTML的程序。旧的

程序使用TABLE排序所有内容。我想改用DIV。


感谢您的帮助。


-


丹尼斯



That is no doubt the answer to my question. But what if I want the width of
the 1st column to be just as wide as whatever text it contains? Leaving off
the width in IE seems to work ... but not for NS.

Feel free to point me to a good tutorial if you would rather.

P.S. What I want to do is rewrite a program that generates HTML. The old
program lines everything up using TABLEs. I would like to use DIVs instead.

Thanks for your help.

--

Dennis


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

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