获取div之外的背景
我想将 div 的背景图像放置在其外部。类似backgroundPosition:-100px 0px
。我的问题是它的行为就像 div
具有溢出属性=隐藏。
我已经做了我需要的内容: http://screencast.com/t/3zo0hp8A3
I want to position the background image of a div outside it. Something like backgroundPosition: -100px 0px
. My problem is that it acts like the div
has the overflow property = hidden.
I've made a scratch of what I need: http://screencast.com/t/3zo0hp8A3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为这是不可能的,并且很难在多个浏览器上工作。
我认为最好的选择是将“Div2”放在另一个 div 中,并设置背景。
I don't think this is possible and will be difficult to get working on multiple browsers.
I think the best option would be to put 'Div2' inside another div, with the background set to that.
好吧,你所想的方式..在任何浏览器中都是不可能的!
给你举了一个小例子: http://jsfiddle.net/hobobne/bFBfh/
这就是 Curt指的是:http://jsfiddle.net/hobobne/bFBfh/3/
根据您的规范,最后一个解决方案是正确的方法。如果您能更多地解释您的更高目标,那么也许我们可以提出更好的解决方案。
Okay, the way you are thinking of.. Is not possible in any browser!
Made you a small example: http://jsfiddle.net/hobobne/bFBfh/
This is what Curt was referring to: http://jsfiddle.net/hobobne/bFBfh/3/
The last solution is the correct way to go, based on your specifications. If you would explain more about your higher goal, then maybe we could come up with even better solution.
您无法使用背景来做到这一点,但您可以使用带有
position:relative
的 html 图像或带有负left
的absolute
图像。You cannot do that with background, but you can use an html image with
position:relative
orabsolute
with a negativeleft
.