调整窗口大小时保持元素与背景的相对位置?

发布于 2024-11-30 13:02:39 字数 439 浏览 1 评论 0原文

我希望徽标在调整窗口大小时“跟随居中背景(图片)的移动”。是否可以 ?我尝试了很多东西,但无法得到它。

背景

div.container{ 宽度:1164px; 高度:776 像素; 边距:0px; 边框:无; 行高:150%;

背景图像:url('背景'); 背景重复:不重复; 背景附件:固定; 背景位置:左:45px;顶部:20px;
}

徽标

logo

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情释 2024-12-07 13:02:39

如果您尝试仅将内容水平居中,您可以尝试
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;}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文