ie7浮动右bug?

发布于 2024-08-11 12:12:12 字数 1633 浏览 4 评论 0原文

我有一个 div 漂浮在右边。该 div 内还有另外两个 div。第一个 div 有背景颜色,当我刷新时,它会“渗入”第二个 div 中。 (有时在它前面,有时在它后面。)当我滚动时,它会自行修复。当我刷新时,它会再次出现。这只发生在 IE7 中。漏洞?下面的代码

#sidebar {float:right;width:310px;}
#articleSidebar {background:#DEE7E7;margin:0 5px 20px 5px;position:relative;}
#articleSidebarHeader {margin-top:10px;padding:5px;}
#articleSidebar h2, #articleSidebarHeader h2 {color:#5A5A5A;font-size:14px;font-weight:bold;}
#articleSidebar ul {color:#5A5A5A;font-size:11px;padding:0 7px;}
#articleSidebar ul li {background: transparent url(../images/bulletSquare9C.png) no-repeat scroll left 6px; padding:0 0 10px 7px;}
#articleSidebar ul li a {color:#5A6B73;display:block;text-decoration:underline;}
#articleSidebar ul li a strong {font-weight:bold;}
#sidebarAd {margin:0 5px 20px 5px;position:relative;}





<div id="sidebar">
        <div id="articleSidebar">
            <div id="articleSidebarHeader">
                <h2>Title here TBD</h2>
            </div>
            <ul>
                <li><a href="replaceMe">link</a>text</li>
                <li><a href="replaceMe">link</a>text</li>
                <li><a href="replaceMe">link</a>text</li>
                <li><a href="replaceMe">link</a>text</li>
            </ul>
        </div>
        <div id="sidebarAd">
        <!--300x250 ad here-->
        <iframe src="http://www.google.com" height="250" width="300" scrolling="no" frameborder="0"></iframe>
        </div>
    </div>

I have a div floated right. Inside that div are two other divs. The first div has a background color and when I refresh, it's "bleeding" into the second div. (Sometimes in front of it sometimes behind it.) When I scroll, it fixes itself. When I refresh it does it again. This is only happening in IE7. Bug? code below

#sidebar {float:right;width:310px;}
#articleSidebar {background:#DEE7E7;margin:0 5px 20px 5px;position:relative;}
#articleSidebarHeader {margin-top:10px;padding:5px;}
#articleSidebar h2, #articleSidebarHeader h2 {color:#5A5A5A;font-size:14px;font-weight:bold;}
#articleSidebar ul {color:#5A5A5A;font-size:11px;padding:0 7px;}
#articleSidebar ul li {background: transparent url(../images/bulletSquare9C.png) no-repeat scroll left 6px; padding:0 0 10px 7px;}
#articleSidebar ul li a {color:#5A6B73;display:block;text-decoration:underline;}
#articleSidebar ul li a strong {font-weight:bold;}
#sidebarAd {margin:0 5px 20px 5px;position:relative;}





<div id="sidebar">
        <div id="articleSidebar">
            <div id="articleSidebarHeader">
                <h2>Title here TBD</h2>
            </div>
            <ul>
                <li><a href="replaceMe">link</a>text</li>
                <li><a href="replaceMe">link</a>text</li>
                <li><a href="replaceMe">link</a>text</li>
                <li><a href="replaceMe">link</a>text</li>
            </ul>
        </div>
        <div id="sidebarAd">
        <!--300x250 ad here-->
        <iframe src="http://www.google.com" height="250" width="300" scrolling="no" frameborder="0"></iframe>
        </div>
    </div>

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

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

发布评论

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

评论(2

瞳孔里扚悲伤 2024-08-18 12:12:12

在 IE6 和 7 中,我通常使用 position:staticzoom:1 这可能会解决问题。

In IE6 and 7 I generally play around with position:static and zoom:1 which may fix the problem.

给不了的爱 2024-08-18 12:12:12

我认为你的相对定位是问题的一部分。两个 DIV 具有相同的相对定位。我认为在 IE7 中,应用“相对”定位之前元素原始位置的位置和高度/宽度可能未正确计算。

我想到的修复方法是:

  1. 使用绝对定位。这会在重新定位之前将元素从 DOM 中取出,同时不会保留它们在页面中占用的空间。在这种情况下,定位值不能相同,否则它们将相互重叠。

  2. 首选方法 使用“浮动”div 来实现与听起来相同的效果。您可以指定边距 CSS 定义来实现相同的视觉布局,而不是相对定位。

    #articleSidebar {背景:#DEE7E7;float:left;margin:0 5px 20px 5px;}    
    #sidebarAd{边距:0 5px 20px 5px;浮动:左;}
    

I think you're relative positioning is part of the problem. Both DIVs have the same relative positioning. I think maybe in IE7 the position and height/width of the elements original position before applying the "relative" positioning is not calculated correctly.

The fixes that come to mind are:

  1. Use absolute positioning. This takes the elements out of the DOM before repositioning, while not holding the space they would have occupied in the page. In this case the positioning values cannot be the same or they will overlay each other.

  2. Preferred method Use "floated" divs to achieve the same effect of what it sounds like you are doing. Rather than the relative positioning, you can specify margin CSS definitions to achieve the same visual layout.

    #articleSidebar {background:#DEE7E7;float:left;margin:0 5px 20px 5px;}    
    #sidebarAd{margin:0 5px 20px 5px;float:left;}
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文