循环IE7层
我在使用一个小 div 时遇到问题,该 div 应该“悬停”在使用 JQuery 循环插件切换的图片上。图片宽 950 像素,图片顶部右侧有一个小框,其中包含最新新闻。
问题是在 IE 的兼容模式下,该框似乎失去了 z 索引并最终位于图片后面。它适用于 IE8、Opera、Chrome 和 Firefox。
我尝试删除 2 张图片,因此只显示 1 张图片,然后由于某种原因它也可以在兼容模式下工作。我尝试删除 img 标签之间的空格,但没有成功,margin: 0; padding: 0 全部都是,但运气不好
有人知道可能出了什么问题吗?
CSS 代码
#Content {
width: 950px;
}
#NewsWrapper {
position: relative;
padding: 0;
margin: 0;
top: 0;
}
#NewsListning {
float: right;
height: 200px;
margin: 0;
padding: 10px;
background: yellow;
top: 0;
right: 0;
position: absolute;
z-index: 12;
width: 300px;
}
#SlideImages {
width: 100%;
margin: 0;
padding: 0;
float: left;
z-index: 11;
}
.SlideImage {
display: inline;
float: left;
padding: 0;
margin: 0;
z-index: 11;
}
JavaScript 代码
$(function () {
$('#SlideImages').cycle({
fx: 'fade',
speed: 5000
});
});
HTML 代码
<div id="Content">
<div id="SlideImages">
<img src="/Images/Slide1.jpg" class="SlideImage" />
<img src="/Images/Slide2.jpg" class="SlideImage" />
<img src="/Images/Slide3.jpg" class="SlideImage" />
</div>
<div id="NewsWrapper">
<div id="NewsListning">
<div>
<strong>Test 2</strong>
Lorem ipsum
</div>
</div>
</div>
- 已解决 - 附加说明*
在除 IE7 之外的所有浏览器中,您需要指定,例如 top: 0; left:0 如果你要使用position:absolute。否则它通常会在现场结束。另一件事对于 IE7 来说是没有意义的。
I have a problem using a small div that should "hover" over pics that switches using the JQuery cycle plugin. The pictures are 950px wide and to the right on top of the pictures a small box should be with latest news.
Problem is in compability mode in IE the box seems to loose it's z-index and ends up behind the picture. It works in IE8, Opera, Chrome and Firefox.
I've tried to remove 2 pictures so only 1 picture shows, and then for some reason it works in compabilitymode aswell. I've tried to remove whitespaces between the img-tags but no luck, margin: 0; padding: 0 all over but no luck
anyone got any ideas what might be wrong?
CSS CODE
#Content {
width: 950px;
}
#NewsWrapper {
position: relative;
padding: 0;
margin: 0;
top: 0;
}
#NewsListning {
float: right;
height: 200px;
margin: 0;
padding: 10px;
background: yellow;
top: 0;
right: 0;
position: absolute;
z-index: 12;
width: 300px;
}
#SlideImages {
width: 100%;
margin: 0;
padding: 0;
float: left;
z-index: 11;
}
.SlideImage {
display: inline;
float: left;
padding: 0;
margin: 0;
z-index: 11;
}
JavaScript Code
$(function () {
$('#SlideImages').cycle({
fx: 'fade',
speed: 5000
});
});
HTML Code
<div id="Content">
<div id="SlideImages">
<img src="/Images/Slide1.jpg" class="SlideImage" />
<img src="/Images/Slide2.jpg" class="SlideImage" />
<img src="/Images/Slide3.jpg" class="SlideImage" />
</div>
<div id="NewsWrapper">
<div id="NewsListning">
<div>
<strong>Test 2</strong>
Lorem ipsum
</div>
</div>
</div>
- SOLVED - ADDITIONAL NOTES*
In all browsers but IE7 you need to specify, for example, top: 0; left:0 if you are gonna use position: absolute. Else it usually ends up right of site. Another thing that doesnt make sense when it comes to IE7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 #NewsWrapper 设置为比 #NewsListing 更高的索引,
这应该可以工作
另外,我还没有查看 Cycle 的代码,但我假设它使用高于 12 的 z-index。您可能想要使用
z-索引
> 1000 表示您希望成为屏幕上最前沿的内容。我刚刚遇到类似的问题非常困难。 (CSS Drop Down 位于横幅下方)我最终使用 CSS 修复了它,将整个导航的父
div
更改为position:absolute
和一个非常高的z-index
但我测试了这个< /a> 效果非常好。Put your #NewsWrapper as a higher index than #NewsListing
That should work
Also, I haven't looked at the code for Cycle but I'm assuming it uses higher z-index than 12. You'll probably want to use
z-index
> 1000 for something you want to be the most forward on the screen.I just had a really hard time with a similar issue. (CSS Drop Down going underneath a banner) I used CSS to eventually fix it, changed the parent
div
holing the whole nav toposition:absolute
and a really highz-index
but I tested this and it worked really well.