ie7浮动右bug?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 IE6 和 7 中,我通常使用
position:static
和zoom:1
这可能会解决问题。In IE6 and 7 I generally play around with
position:static
andzoom:1
which may fix the problem.我认为你的相对定位是问题的一部分。两个 DIV 具有相同的相对定位。我认为在 IE7 中,应用“相对”定位之前元素原始位置的位置和高度/宽度可能未正确计算。
我想到的修复方法是:
使用绝对定位。这会在重新定位之前将元素从 DOM 中取出,同时不会保留它们在页面中占用的空间。在这种情况下,定位值不能相同,否则它们将相互重叠。
首选方法 使用“浮动”div 来实现与听起来相同的效果。您可以指定边距 CSS 定义来实现相同的视觉布局,而不是相对定位。
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:
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.
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.