IE7 中奇怪的浮动错误

发布于 2024-08-04 03:30:04 字数 907 浏览 5 评论 0原文

在我正在处理的网页上这里,我有一个主要的div,并且在主要的内部div 和图像 div。粗略地说,重要的 HTML 是:

<div id="wrapper">
    <div id="main">
        <div class="images">
            <p>Content</p>
            <div class="clear"></div>
        </div>
        <p>Text...</p>
    <div class="clear"></div>
    </div>
</div>

和 CSS:

div#wrapper
{
    padding: 10px;
    width: 90%;
}

div#main
{
    padding: 5px;
}

div.images
{
    float: right;
    width: 320px;
    margin-left: 5px;
}

div.clear
{
    height: 0;
    clear: both;
}

很抱歉,如果问题的原因不在此处的代码中,但我认为是这样。

问题是,当 images div 变得比 main div 的内容大时,wrapper div 就会失去其左内边距;并且 main 的底部填充增加。该问题似乎只出现在 IE7 中。

On the webpage I'm working on here, I have a main div, and within the main div, and image div. Roughly speaking, the important HTML is:

<div id="wrapper">
    <div id="main">
        <div class="images">
            <p>Content</p>
            <div class="clear"></div>
        </div>
        <p>Text...</p>
    <div class="clear"></div>
    </div>
</div>

and the CSS:

div#wrapper
{
    padding: 10px;
    width: 90%;
}

div#main
{
    padding: 5px;
}

div.images
{
    float: right;
    width: 320px;
    margin-left: 5px;
}

div.clear
{
    height: 0;
    clear: both;
}

Apologies if the cause of the problem is not within the code here, but I think it is.

The problem is, when the images div becomes larges than the content of the main div, the wrapper div loses its left padding; and the bottom padding of main increases. The problem only seems to occur in IE7.

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

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

发布评论

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

评论(1

深空失忆 2024-08-11 03:30:04

事实证明,给出 #main hasLayout 就可以了。

div#main
{
    zoom: 1;
}

将其放入 IE7 样式表中,它就基本修复了。底部的边框仍然很大,但不太重要。

Turns out that giving #main hasLayout does the trick.

div#main
{
    zoom: 1;
}

Put this in the IE7 stylesheet, and it's pretty much fixed. Still to large a border at the bottom, but not too important.

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