即 7-9 未正确显示位置:绝对

发布于 2024-12-03 05:42:52 字数 1464 浏览 2 评论 0原文

我有一个带有 z-index:1-100(随 javascript 更改) 和position:absolute 的 div。在里面我有一个带有 z-index:101 和position:absolute的a href。

所有 webbbrowsers 都会将其呈现为 101 显示在顶部(正确) 但在 ie 7-8-9 中却没有...为什么呢? 这里确实需要一些帮助!

代码:

     <div id="bannerad">
     <a target="_blank" style="position:absolute;z-index:101;width:680px;height:120px;" class="mcdFade" href="http://www.mcdonalds.se"></a>
     <div id="fadea" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/1.jpg" width="800" height="120" alt="Fade"/></div>
     <div id="fadeb" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/2.jpg" width="800" height="120" alt="Fade"/></div>
     <div id="fadec" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/3.jpg" width="800" height="120" alt="Fade"/></div>   
     </div>

生成EDIT

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

由 Visual Studio

EDIT 2 添加了 jsfiddle http://jsfiddle.net/Pesmd/18/ 但无法让它工作,你只能稍微看到图像,但它可以在我的浏览器中运行

编辑 3 这似乎是 IE 中的一个主要问题,我已经尝试了我找到的解决方案,但没有结果。这里没有人可以帮助我解决这个问题吗?

据我所知,当您的父级的位置设置为默认值以外时, z-index 属性会重置,但我仍然无法让它工作。

I have a div with z-index:1-100(changes with javascript) and position:absolute. inside that i have an a href with z-index:101 and position:absolute.

All webbbrowsers renders this as the one with 101 is displayed on top (correctly)
but in ie 7-8-9 it doesnt... why is that?
Could really use some help here!!

CODE:

     <div id="bannerad">
     <a target="_blank" style="position:absolute;z-index:101;width:680px;height:120px;" class="mcdFade" href="http://www.mcdonalds.se"></a>
     <div id="fadea" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/1.jpg" width="800" height="120" alt="Fade"/></div>
     <div id="fadeb" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/2.jpg" width="800" height="120" alt="Fade"/></div>
     <div id="fadec" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/3.jpg" width="800" height="120" alt="Fade"/></div>   
     </div>

EDIT

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

generated by visual studio

EDIT 2
Added jsfiddle http://jsfiddle.net/Pesmd/18/ but cant get it to work, you only see the image slightly, it works in my browser though

Edit 3
This seems to be a major problem in IE, i have tried the solutions i found without result. Is there no1 here that can help me with this problem?

What i know, the z-index property resets when you have a parent with a position other then default set to them, but i still cant get it to work.

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

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

发布评论

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

评论(2

悲喜皆因你 2024-12-10 05:42:52

将锚点设置为 display:block 看看是否有效。然后在测试时在元素上添加一个大的 3px 绿色边框,以便您可以更好地看到它。

set anchor to display:block see if that works. Then add a big 3px green border on the element when your testing so you can see it better.

云裳 2024-12-10 05:42:52

为什么不直接将链接包裹在 div 周围呢?

<div id="bannerad"> 
    <a target="_blank" style="position:absolute;z-index:101;width:680px;height:120px;" class="mcdFade" href="http://www.mcdonalds.se">
        <div id="fadea" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/1.jpg" width="800" height="120" alt="Fade"/></div>
        <div id="fadeb" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/2.jpg" width="800" height="120" alt="Fade"/></div>
        <div id="fadec" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/3.jpg" width="800" height="120" alt="Fade"/></div>
    </a>
</div>

编辑:我看了你的小提琴并让它发挥作用。它的设计与您想要的不同,但它很简单,并且无需担心 z-index 即可完成工作: http://jsfiddle.net/kCsvG/3/

Why not just wrap your link around the divs?

<div id="bannerad"> 
    <a target="_blank" style="position:absolute;z-index:101;width:680px;height:120px;" class="mcdFade" href="http://www.mcdonalds.se">
        <div id="fadea" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/1.jpg" width="800" height="120" alt="Fade"/></div>
        <div id="fadeb" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/2.jpg" width="800" height="120" alt="Fade"/></div>
        <div id="fadec" style="position:absolute;visibility:hidden;"><img src="Images/Ads/McDHstad/3.jpg" width="800" height="120" alt="Fade"/></div>
    </a>
</div>

Edit: I looked at your fiddle and made it work. It's a different design than you were going for, but it's simple and gets the job done without having to worry about z-index: http://jsfiddle.net/kCsvG/3/

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