IE6定位问题

发布于 2024-08-10 22:21:04 字数 384 浏览 2 评论 0原文

它在 Safari、Firefox 等中按预期工作。但它不会读取 IE6 中的定位或 z-index。我怎样才能使它的布局在 IE6 中应有的样子?

这是CSS:

.AuthorName_Pic {
    width: 186px;
    position: absolute;
    right: 0;
    bottom: -120px;
    padding: 20px 10px 20px 15px;
    margin: 20px 0 0 0;
    background: url(images/ThumbDark.jpg) no-repeat;
    z-index:100;
}

It works as intended in Safari, Firefox etc. But it is not reading the positioning or z-index in IE6. How can I make it layout as it should in IE6?

Here is the CSS:

.AuthorName_Pic {
    width: 186px;
    position: absolute;
    right: 0;
    bottom: -120px;
    padding: 20px 10px 20px 15px;
    margin: 20px 0 0 0;
    background: url(images/ThumbDark.jpg) no-repeat;
    z-index:100;
}

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

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

发布评论

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

评论(2

踏月而来 2024-08-17 22:21:04

您需要解决盒子模型错误。我会使用 Tantek 的解决方案

You'll need to address the box model bug. I would use Tantek's solution.

香草可樂 2024-08-17 22:21:04
  1. 确保您使用的是标准模式而不是Quirks,否则“宽度”的含义和IE 中的“高度”与其他浏览器不同。这是 Josh 提到的盒子模型错误,但你不想想在当今时代使用盒子模型黑客(尤其不是 Tantek 最初且仍然是最丑陋的)一)。 IE5 需要 BMH,但如今已被埋没,因为标准模式解决了该问题以及更多问题。

  2. 你说 z-index 在某种程度上是错误的。没有足够的信息可以肯定,因为您只发布了代码的一小部分,但此问题的一个常见根源是 IE 在您给出“位置”的任何元素上设置默认的“z-index”堆栈上下文'(相对/绝对),即使您不包含 z-index 属性。确保您定位的所有元素也都有 z 索引,以确保跨浏览器的布局一致。

  1. Ensure you are using Standards Mode not Quirks, otherwise the meaning of ‘width’ and ‘height’ is different in IE to other browsers. This is the box model bug as mentioned by Josh, but you don't want to be using a Box Model Hack in this day and age (especially not Tantek's original-and-still-the-worst ugly one). BMHs were needed for IE5 but today are dead and buried, as Standards Mode fixes that issue and a lot more.

  2. You say the z-index is wrong in some way. There isn't enough information to say for sure since you have only posted a small part of your code, but a common source of this problem is that IE sets a default ‘z-index’ stacking context on any element you give a ‘position’ (relative/absolute) even when you don't include the z-index attribute. Ensure all the elements you have positioned are also z-indexed to ensure consistent layout cross-browser.

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