Webkit SVGforeignObject 背景分层错误的解决方法?

发布于 2024-12-20 01:03:10 字数 452 浏览 3 评论 0原文

当使用foreignObject标签在SVG中嵌入html时,基于webkit的浏览器会渲染svg元素后面嵌入的html元素的背景。请参阅 http://code.google.com/p/chromium/issues/详细信息?id=35545

这是一个示例: http://www.mxgraph.com/demo/markup/webkitbg.html 绿色 div 应该位于红色上面。

有谁知道这个问题的解决方法?也许 z-index 和/或元素分组或 svg 中的某些内容可以欺骗 webkit 做正确的事情?

When embedding html inside of SVG using the foreignObject tag, webkit based browsers render the backgrounds of the embedded html elements behind the svg elements. See http://code.google.com/p/chromium/issues/detail?id=35545 .

Here's an example : http://www.mxgraph.com/demo/markup/webkitbg.html
The green div should be on top of the red.

Does anyone know of a workaround for this issue? Maybe some incantation of z-index and/or grouping of elements or something in svg to fool webkit into doing the right thing?

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

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

发布评论

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

评论(2

云仙小弟 2024-12-27 01:03:10

这是 webkit 错误 58417,已于 2011 年 11 月 10 日修复。该修复已在 Chromium 版本 17 中进行,该版本目前于 2012 年 1 月 9 日处于测试阶段,预计将于 2 月初发布。不确定修复何时会登陆 Safari,但幸运的是我不需要支持它。

所以解决方法似乎是“等待一个月”......

This is webkit bug 58417, fixed on 2011-11-10. The fix is in Chromium version 17, which is currently in beta as of 2012-01-09, and should be released in early February. Not sure when the fix will land in Safari, but luckily I don't need to support it.

So the workaround seems to be "wait a month"...

薄情伤 2024-12-27 01:03:10

我刚刚遇到了同样的问题。尽管这个 bug 在 Chrome 中已经修复了很长时间,但 Safari 的代码库似乎落后了很多年。

我的解决方案是将 style="display:inline-block" 添加到 foreignObject 标记的第一个子级。这似乎可以解决问题。

I've just been hit by the same issue. Even though the bug is fixed since a long time in Chrome, Safari seems to be ages behind with the codebase.

My solution is to add style="display:inline-block" to the first child of the foreignObject tag. This seems to fix the problem.

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