CSS IE6浮动向右对齐

3
当我将div样式设置为display:block; float:right时,为什么在IE6中该div仍然会出现在文本下方,而不是像其他浏览器(包括IE7+)一样浮动到右侧的中间。如果我将display设置为inline,则div内部的菜单会混乱。我需要保持display:block的设置。
.content { display:block; }
.float { width:150px; display:block; float:right; }
.nothing { display:inline; }
请注意,在IE6中,float类不会显示在nothing类的右侧,而是出现在其下方。是否有解决方法?
<span>This is some text </span>

<div style="float: right;">
    This is floated text
</div>

输出结果如下:
这是一些文本
这是浮动的文本
如果您将span向左浮动,或者
<span style="float:left;">This is some text </span>

<div style="float: right;">
    This is floated text
</div>

交换文本和浮动的顺序

<div style="float: right;">
        This is floated text
</div>

<span>This is some text </span>

它正常工作:

这是一些文本    这是浮动文本

也许您可以包含一些HTML并接受您之前的答案。 - metrobalderas
也许这个问题更适合在doctype.com上发布? - Nick Bolton
1
在doctype上已经有一个类似的问题:http://doctype.com/wierd-ie6-float-issue - Greg
2个回答

1
跟随 Greg 在评论中发布的链接(doctype.com/wierd-ie6-float-issue)获取有效解决方案。基本上将您的浮动元素放在 HTML 中的第一位。

0
这可能不是您的情况下的选项,但也许您可以尝试在父元素中使用float: leftalign: right? 这在过去对我有用过,但并非在每种情况下都有用。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接