IE8 CSS 绝对定位随机错误

发布于 2024-08-08 01:54:52 字数 339 浏览 0 评论 0原文

我在 IE8 中遇到了一个令人沮丧但看似随机的渲染错误。我在页面上有一些绝对定位的元素(相对于页面主体定位),其显示由 jQuery 切换。

十分之八的元素被正确渲染,但有时不遵守定位,它们只是简单地放置在浏览器窗口的左上角(实际上绝对定位在顶部 0,左侧 0)。

如果我查看 IE 开发工具栏中的元素属性,我可以看到设置了正确的 css 属性 - 只是没有应用它们。如果我调整浏览器窗口的大小,那么该元素将跳转到正确的位置 - 所以它看起来确实像一个真正的渲染错误。

我在页面上设置了正确的 DOCTYPE,因此浏览器不处于怪异模式。

我有什么想法可以解决这个问题,或者其他人也经历过类似的事情吗?

I'm encountering a frustrating but seemingly random rendering bug in IE8. I have some absolutely positioned elements on the page (positioned in relation to the page body), the displaying of which are toggled by jQuery.

8 times out of 10 the elements are rendered correctly, but sometimes the positioning is not obeyed and they are simply placed in the top left corner of the browser window (effectively absolute positioned at top 0, left 0).

If I look at the element properties in the IE Developer Toolbar, I can see that the correct css properties are set - they are just not being applied. If I resize the browser window, then the element will jump to its correct position - so it does look like a genuine rendering bug.

I'm setting a correct DOCTYPE on the page, so the brower isn't in quirks mode.

Any ideas how I can combat this or has anyone else experienced similar?

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

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

发布评论

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

评论(4

人事已非 2024-08-15 01:54:52

如果我没记错的话,当尝试在显示某物之前设置其位置时就会出现问题。

例如

  1. 隐藏对象
  2. 设置位置
  3. 显示对象

对象将出现在左上角,直到再次设置位置或调整窗口大小迫使IE重新计算位置

If I recall correctly, the problem occurs when trying to set the position of something before it is displayed.

e.g.

  1. hide object
  2. set position
  3. show object

The object will appear in the top left, until the position is set again or the window is resized forcing IE to re-calculate positions

半山落雨半山空 2024-08-15 01:54:52

您是否尝试过 IE8 特定属性:

-ms-background-position-x: 1px;
-ms-背景位置-y:29px;

它们仅适用于 IE8,并解决了这个问题。

Have you tried the IE8 specific properties:

-ms-background-position-x: 1px;
-ms-background-position-y: 29px;

They only work in IE8 and address this exact issue.

诗笺 2024-08-15 01:54:52

有类似的问题-> IE8 文本框不可编辑(当我的应用程序的包装具有位置:绝对时)。单击仅在边框中起作用。填充颜​​色和透明也不起作用。通过此文档类型更改,问题得到解决。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

资料来源: http://www.codingforums.com/showthread.php?p=1173375 #post1173375

Had the similar issue -> IE8 textbox was not editable (when wrapper of my App has position:absolute). Click worked only in the border. Filled with color and transparent also did not work. With this doctype change the issue is fixed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

Source: http://www.codingforums.com/showthread.php?p=1173375#post1173375

梦境 2024-08-15 01:54:52

我也经历过这种情况,我正在使用一些 jquery 来显示一个绝对定位的元素,该元素仅在单击另一个元素时才可见。微软继续把基本原理搞得完全错误,这真是太奇怪了。

I too have experienced this, I am using some jquery to show an absolutely positioned element that is only visible when another element is clicked. How odd that Microsoft continue to get the basics completely wrong.

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