在 Opera 和 Chrome 中,背景图像出现在前景图像之上
我有一个带有背景图像的小跨度。该背景图像滚动到前景图像下方。虽然这在 IE 和 FF 中完美运行,但在 Opera 和 Chrome 中不起作用。
我已将示例放在此处。请看带有 4 个小矩形的块。
请提出解决方案。
I've a tiny span with a background image. This background image scrolls below foreground image. While this works perfectly in IE and FF, it doesn't work in Opera and chrome.
I've put my example here. PLease see the block with 4 small rectangles.
PLease suggest solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
display:block
添加到您的范围中。内联元素没有高度或宽度,因此会显示整个背景,而不是根据图像大小进行裁剪。
评论后编辑
是否有任何原因无法将背景图像应用到 img 标签本身?这将在跨浏览器上更加一致。
You need to add
display:block
to your span.Inline elements do not have a height or width so the whole background is being displayed instead of being cropped by the image size.
Edit after comments
Is there any reason you can't apply the background image to the img tag itself? That would be more consistent cross-browser.