内联 svg - 如何将浏览器默认样式应用于foreignObject中的xhtml?
我有一个内联 svg,其中包含包含 xhtml 片段的 foreignObject
元素。但是,由于 svg 及其父 html 文档(即 jqtouch 库)中通过 js 设置的样式的串扰,xhtml 内容的样式不正确。因此我想将浏览器默认样式应用于我的 foreignObject
的子级。因此我需要引用浏览器默认样式表。有人知道该怎么做吗?对于 safari,我可能可以从 webkit 源获取它,但我更喜欢一个不需要在浏览器升级后跟踪修改的解决方案。
使用本机 svg 文本元素不是一个选项,因为自动换行是强制的。 也不是...
- 将内联 svg 子树移出顶级 css 范围。
- 修改有问题的顶级 CSS (事实上,修改每个CSS选择器并向外部的每个元素添加一个唯一的CSS类 如果可以以编程方式高效地完成,
foreignObject
可能会成为一种选择。 希望有一个更优雅的解决方案?)
平台: Safari 5.0.3 (7533.19.4) 赢得 XP SP3
提前感谢您的努力
最好的问候,卡斯滕
i have an inline svg with foreignObject
elements which contain xhtml fragments. however, the xhtml content is improperly styled due to crosstalk from styles set through js in the svg and its parent html document (namely the jqtouch library). thus i'd like to apply the browser default styles to the children of my foreignObject
s. therefore i need to reference the browser default style sheet. does anybody know how to do this ? for safari i could probably take it from the webkit sources but i'd prefer a solution that doesn't require keeping track of modifications after a browser upgrade.
using the native svg text elements is not an option as automatic word wrapping is mandatory.
neither is ...
- moving the inline svg subtree out of the toplevel css scope.
- modifying the offending toplevel css
(in fact, modifying every css selector and adding a unique css class to every element outside
theforeignObject
s might become an option, if it can be done programmatically and efficiently.
hopefully there is a more elegant solution ?)
platform:
safari 5.0.3 ( 7533.19.4 )
win xp sp3
thanks in advance for your efforts
best regards, carsten
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想只有当您将 xhtml 作为带有 head body 等的整个文档嵌入时才会应用默认样式
I guess the default styles will be applied only if you embed the xhtml as a whole document with head body etc