Firefox/Opera 是否可以处理定位/多个背景图像?
在 Firefox/Opera 中显示特定背景图像时遇到问题,所有其他浏览器都在玩球(显然 IE 除外,为此我不得不妥协)。
目前,Opera 不允许使用多个背景图像,如下所示:
background-image: url('/images/h2_default_bg.png'), url('/images/dashed_bg_default.gif');
background-repeat: no-repeat, repeat-x;
background-position: top left, bottom left;
另外,当背景图像以像素为单位定位时,Firefox 和 Opera 都显得很尴尬:
background: url('/assets/images/dashed_bg.gif') bottom 2px repeat-x;
对于这些问题是否有任何简单的解决方法?
Having issues getting specific background images to display in Firefox/Opera, all other browsers are playing ball (except obviously IE, for which I've had to compromise).
Currently, Opera won't allow multiple background images like so:
background-image: url('/images/h2_default_bg.png'), url('/images/dashed_bg_default.gif');
background-repeat: no-repeat, repeat-x;
background-position: top left, bottom left;
Also both Firefox and Opera are both being awkward when a background image is positioned in pixels:
background: url('/assets/images/dashed_bg.gif') bottom 2px repeat-x;
Are there any simple workarounds for either of these problems?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
仅从 Firefox 3.6 和 Opera 10.5。这些是您正在测试的版本吗? Chrome 和 Safari 已经支持它们,我想你的意思是“所有其他浏览器......显然除了 IE”
至于你的第二个问题, 规范对
background-position
语法进行了如下说明:所以你给它们的顺序是错误的。改为
2px 底部
。Multiple backgrounds are only supported starting from Firefox 3.6 and Opera 10.5. Are those the versions you're testing in? Chrome and Safari already support them, which I presume you mean with "all other browsers ... except obviously IE"
As for your second problem, the spec says this about the
background-position
syntax:So you've given them in the wrong order. Make it
2px bottom
instead.CSS2 / 2.1 中不可能有这样的多个背景图像,目前我们仍然 必须遵守。
请参阅此目前浏览器支持多种背景的 quirksmode 页面。
至于其他设置,背景位置肯定可以跨浏览器工作,我不知道那里有任何不兼容之处。 Firefox 和 Opera 中到底发生了什么?
Multiple background images like that are not possible in CSS2 / 2.1, which at the moment we still have to adhere to.
See this quirksmode page on which browsers currently support multiple backgrounds.
As for the other settings, background position definitely works across browsers, I'm not aware of any incompatibilies there. What exactly happens in Firefox and Opera?
正如您所发现的,多种背景适用于所有现代浏览器。从版本 10.5 开始,它可以在 Opera 中运行。没有关于 IE9 是否拥有它以及 IE 是否/何时支持它的信息。
As you found out, multiple backgrounds works in all the modern browsers. It does work in Opera as of version 10.5. There is no information on whether IE9 will have it nor if/when IE will ever support it.