IE7 中绝对定位元素的 Z 索引问题

发布于 2024-12-05 15:52:57 字数 1536 浏览 0 评论 0原文

我有一个带有连接器 div 的文本区域,表示用户当前状态。连接器 div 是绝对定位的,因此它与文本区域一起形成一个谈话气泡来象征用户正在“说”的内容。连接器将放置在文本区域的“顶部”(通常是较高的 z-index),它在每个浏览器中都可以正常工作,但不幸的是我必须支持 IE7。在 IE7 中,connector-div 放置在文本区域下方,这就是问题所在。

我在 IE7 中搜索了 Z-index bug 的问题,并尝试了几种找到的解决方案,但没有一个解决方案适合我的特定情况。

我有以下简化的 html:

  <form class="current-status">
    <div class="talk-bubble">
      <div class="connector"> "Absolute positioned with high z-index.." </div>
      <textarea> "User status goes here" </textarea>
    </div>
  </form>

current-status-div 只是静态定位, talk-buble-div 是相对的, Connector-div 是绝对的,z-index 为 4, textarea 是相对的,目前没有 z-index,因为它可以在除 ie7 之外的任何地方使用。 但我尝试在 texarea 上设置低 z-index,在连接器上设置高 z-index,但 IE7 的堆叠很奇怪。

我尝试了很多不同的解决方案,包括定位、z-indexing、包装元素等,但似乎没有任何效果。

有人有主意吗?

一些与该问题相关的CSS:

.content-box-plate {
    position: relative;
    z-index: auto;
}

.talk-bubble {
    position: relative;
    z-index: auto;
}

.connector {
    background: url("/images/portal/bubble_connector.png?1314369295") no-repeat scroll center center transparent;
    height: 12px;
    position: absolute;
    right: 5px;
    width: 21px;
    z-index: 4;
}
textarea {
    font-size: 13.5px;
    font-style: italic;
    height: 40px;
    line-height: 1.25em;
    overflow: auto;
    padding: 6px 6px 6px 8px;
    position: relative;
    width: 165px;
    z-index: auto (tried to put a specific value lower than connectors without effect)
}

I have a textarea with a connector div that represents a users current status. The connector-div is absolute positioned so that it together with the textarea forms a talk-bubble to symbolize what the user is "saying". The connector is to be placed "on top" of the textarea (normally a higher z-index) and it works fine in every browser but IE7 which I unfortunatly have to support. In IE7 the connector-div is placed below the textarea and thats the issue.

I've googled the issue with Z-index bug in IE7 and tried several solutions i've found but none has solved it for my particular case.

I have the following simplified html:

"

  <form class="current-status">
    <div class="talk-bubble">
      <div class="connector"> "Absolute positioned with high z-index.." </div>
      <textarea> "User status goes here" </textarea>
    </div>
  </form>

"

current-status-div is just static positioned,
talk-bubble-div is relative,
connector-div is absolute with z-index 4,
textarea is relative and currently has no z-index since it works everywhere but ie7.
But I tried setting low z-index on texarea and high on connector but IE7 has wierd stacking..

Ive tried lots of different solutions with positioning, z-indexing, wrapping elements etc. but nothing seems to work.

anyone have an idea?

some css connected to the issue:

.content-box-plate {
    position: relative;
    z-index: auto;
}

.talk-bubble {
    position: relative;
    z-index: auto;
}

.connector {
    background: url("/images/portal/bubble_connector.png?1314369295") no-repeat scroll center center transparent;
    height: 12px;
    position: absolute;
    right: 5px;
    width: 21px;
    z-index: 4;
}
textarea {
    font-size: 13.5px;
    font-style: italic;
    height: 40px;
    line-height: 1.25em;
    overflow: auto;
    padding: 6px 6px 6px 8px;
    position: relative;
    width: 165px;
    z-index: auto (tried to put a specific value lower than connectors without effect)
}

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

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

发布评论

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

评论(1

不语却知心 2024-12-12 15:52:57

如果没有您的代码,很难回答,但是您还需要在父 div 上设置 z-index,这是我在 IE6/7 中修复的常见问题,因为我也必须支持它们。

你可能不需要走到表单那么远,但是如果没有你的 css 并看到它的实时效果,很难说 - 这个或类似的东西会修复它!

您需要位置才能拥有有效的 z 索引,不用担心页面上的其他 z 索引等。因为这是封装在表单中的;当然,将值更改为您想要的任何值,但这就是排序。

<form class="current-status" style="position:relative; z-index:1;">
    <div class="talk-bubble" style="position:relative; z-index:1;">
      <div class="connector" style="position:absolute; z-index:2"> "Absolute positioned with high z-index.." </div>
      <textarea style="position:relative; z-index:1"> "User status goes here" </textarea>
    </div>
</form>

Without your code its difficult to answer however you need to set the z-index on the parent divs as well, its a common issue I fix in IE6/7 since I have to support them as well.

You might not need to go up as far as the form but without your css and seeing it live it's difficult to say - this or thereabouts will fix it though!

You need position to have a valid z-index, dont worry about other z-index on the page etc..since this is encapsulate within the form; of course change the values to whatever you want, but that is ordering.

<form class="current-status" style="position:relative; z-index:1;">
    <div class="talk-bubble" style="position:relative; z-index:1;">
      <div class="connector" style="position:absolute; z-index:2"> "Absolute positioned with high z-index.." </div>
      <textarea style="position:relative; z-index:1"> "User status goes here" </textarea>
    </div>
</form>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文