gpt4 book ai didi

html - IE 6 z-index 和位置 : fixed; issue

转载 作者:太空宇宙 更新时间:2023-11-04 05:16:16 25 4
gpt4 key购买 nike

这是我一段时间以来一直试图解决的问题!我四处寻找解决方案,但找不到。首先是我的 html 的结构(只是骨架框架)-

<body>
<div class="header"> </div>
<div id="content-wrapper">
<a href="/some.html"><div class="feedback_div"></div></a>
</div>
<div id="footer-wrapper"></div>
</body>

现在我的.feedback div 已被定位固定 并给出了top: 40%;right: 0;还有 z-index(当然)。虽然这在所有浏览器中都正常工作,但 IE 6 却把它搞砸了。所以为了在 IE 6 上复制它的效果,我得到了这个解决方案 -

/* IE 6 only */
* .feedback_div
{
z-index: 9998;
position: absolute;
top: expression( (( t=document.documentElement.scrollTop) ? t: document.body.scrollTop) +'px');
right: -140px;
}
* #content-wrapper
{
position: relative;
z-index: 9999;
}
* #footer-wrapper
{
z-index: 0;
position: relative;
}
* html
{
overflow: auto;
}
* html body
{
height: 100%; /* required */
}
/* END: IE 6 only */

但现在的问题是,虽然 .feedback div 在您滚动时跟随您,但当它到达 .footer div 时,反馈 div 在它后面。我尝试使用 z-index,但没有任何效果。

现在我知道理想的解决方案是重新构建 html,使 .feedback div 成为 <body> 的子元素。 .但我不想改变结构,因为这意味着在后端乱搞。我希望仅针对 ie .. 解决此问题,所以只要它按预期工作,即使是某种形式的 hack 也可以。

那么有人对此有解决方案吗?任何帮助将不胜感激。

最佳答案

代码中有一些错误:

  • 您在 a 标签内有一个 div 标签,该标签无效。浏览器会将 div 元素移到 a 元素之外。
  • 你在 div 上有 class="feedback",但你在 CSS 中使用 .feedback_div,所以样式不会不适用。

当您使用 z-index 时,它应用于同一级别的元素,因此您可以将它应用于反馈元素的父级,因为它与页脚处于同一级别。

关于html - IE 6 z-index 和位置 : fixed; issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7963104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com