调整窗口大小时保持元素与背景的相对位置?
我希望徽标在调整窗口大小时“跟随居中背景(图片)的移动”。是否可以 ?我尝试了很多东西,但无法得到它。
背景
div.container{ 宽度:1164px; 高度:776 像素; 边距:0px; 边框:无; 行高:150%;
背景图像:url('背景'); 背景重复:不重复; 背景附件:固定; 背景位置:左:45px;顶部:20px;
}
徽标
I'd like the logo to "follow the movement" of the centered background (a picture) when resizing the window. Is it possible ? I've tried a lot of things, but couldn't get it.
Background
div.container{
width:1164px;
height: 776px;
margin:0px;
border:none;
line-height:150%;
background-image: url('background');
background-repeat: no-repeat;
background-attachment:fixed;
background-position:left:45px;top:20px;
}
Logo
<img style="position:fixed;left:45px;top:20px;" src="/logo" width="205" height="234" alt="logo"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您尝试仅将内容水平居中,您可以尝试
div.container{边距:0 自动}
然后像这样把背景图片放在身体上
正文 {背景图像:url('背景');背景位置:50% 0px;}
If you are trying to center the content only horizontally you can try
div.container{margin:0 auto}
and put the background image on the body like this
body {background-image: url('background'); background-position: 50% 0px;}