使用repeat-y进行背景定位
我有一个背景图像,它只是页面主要内容的包装。
我已将此图像设置为背景图像,如下所示:
#background {
background: url("../image/bg.png") repeat-y 133px 50px;
color: #000000;
font-family: Arial,Helvetica,sans-serif;
margin: 0;
padding: 0;
}
我本以为这会将图像定位在距离左侧 133 像素、距离顶部 50 像素的位置,但它与浏览器顶部齐平。
谁能解释一下为什么这样做?
谢谢
当图像有repeat-y
时可以完成这种位置吗?
谢谢
I have a background image, that is simply a wrapper for the main content of my page.
I have set this image a background image like:
#background {
background: url("../image/bg.png") repeat-y 133px 50px;
color: #000000;
font-family: Arial,Helvetica,sans-serif;
margin: 0;
padding: 0;
}
I would have thought that this would position the image 133px from the left and 50px from the top, but it is flush against the top of the browser.
Can anyone shed any light on why this is doing this?
Thanks
Can this kind of position be done when the image has repeat-y
?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用
repeat-y
,因此背景会垂直重复,向下和向上。您指定的值 -50px
- 是原始背景开始的位置,但如果您的背景高度为 50px,您将不会注意到差异,因为它也会在其上方重复。You are using
repeat-y
so the background is repeated vertically, both down and up. The value you specified -50px
- is the place where the original background starts, but if your background has a height of 50px, you will not notice the difference as it is repeated above it as well.