在IE6中,如何将项目向右浮动而不清除它?

发布于 2024-09-28 22:35:03 字数 596 浏览 0 评论 0原文

在 IE6 中,HTML 如下:

<div id="topmenu">
    <ul>    
        <li>num 1</li>
        <li>num 2</li>
    </ul>
    <div id="rightItem">Hello World</div>
</div>

CSS 如下:

#rightItem {
    cursor: pointer;
    float: right;
    clear: none;
    height: 100%;
    width: 340px;
}

#topmenu {
    margin: 0 auto;
    text-align: left;
    width: 960px;
    height: 41px;
}

在除 IE6 之外的所有浏览器中,它都将 itemRight 浮动到同一行的右侧(首先是 UL,然后是 rightItem)。 在IE6中,它是CLEARING并向右浮动。如何修复 IE6 的问题?

In IE6, HTML is as under:

<div id="topmenu">
    <ul>    
        <li>num 1</li>
        <li>num 2</li>
    </ul>
    <div id="rightItem">Hello World</div>
</div>

The CSS is as under:

#rightItem {
    cursor: pointer;
    float: right;
    clear: none;
    height: 100%;
    width: 340px;
}

#topmenu {
    margin: 0 auto;
    text-align: left;
    width: 960px;
    height: 41px;
}

It is floating the itemRight to right side on the same line (first UL and then rightItem) in all browsers except IE6.
In IE6, it is CLEARING and FLOATING to the right. How can I fix it for IE6?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半世晨晓 2024-10-05 22:35:03

我怀疑 #rightItem 并没有 实际上是清除的,但它的宽度在 IE6 中不同(更宽),这导致它向下推到下一行。

浮动元素应始终指定宽度;首先尝试这样做,看看会得到什么结果。在没有看到更多 HTML 或 CSS 的情况下,这是我最好的猜测,我只是猜测,因为我厌倦了在评论字段中输入“发布更多代码”一词......

I suspect that #rightItem isn't actually clearing, but that it's width is different (wider) in IE6, which is causing it to push down onto the next line.

Floated elements should always have a width specified; try doing that first and see what results you get. Without seeing more of your HTML or CSS this is my best guess, and I'm only guessing because I'm tired of typing the words 'post more code' into comment fields...

南七夏 2024-10-05 22:35:03

添加溢出:隐藏;到#topMenu。适用于所有浏览器。

请参阅:http://www.quirksmode.org/css/clearing.html

Add overflow:hidden; to #topMenu. Works in all browsers.

See: http://www.quirksmode.org/css/clearing.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文