CSS: 背景位置: ???;

发布于 2024-08-17 15:46:04 字数 284 浏览 3 评论 0原文

希望这些图能够解释我所追求的内容。红色表示背景,灰色表示网页。

错误

由 imgur.com 托管

正确

托管by imgur.com

我该如何实现这一目标?我已经尝试过 background-position: Bottom right; 但它完全错误。

Hopefully these diagrams explain what I'm after. The red signifying the background and the grey the webpage.

Wrong

Hosted by imgur.com

Right

Hosted by imgur.com

How do I achive this? I've tried background-position: bottom right; but it's just all wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

感悟人生的甜 2024-08-24 15:46:04

对我来说效果很好:

body
{ 
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-attachment:fixed;
background-position:bottom right; 
}

如果图片足够大,则不需要重复。 (甚至在 IE6 中也能工作)。

Works fine for me:

body
{ 
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-attachment:fixed;
background-position:bottom right; 
}

And if the picture is big enough the no-repeat isn't needed. (Works even in IE6).

风筝在阴天搁浅。 2024-08-24 15:46:04
background-position: right bottom; 

应该可以解决问题。

参考:CSS background-position 属性

xpos ypos - 第一个值是水平位置,第二个值是垂直位置。左上角为 0 0。单位可以是像素 (0px 0px) 或任何其他 CSS 单位。如果仅指定一个值,则另一值为 50%。您可以混合%和位置

background-position: right bottom; 

should do the trick.

Reference: CSS background-position Property

xpos ypos - The first value is the horizontal position and the second value is the vertical. The top left corner is 0 0. Units can be pixels (0px 0px) or any other CSS units. If you only specify one value, the other value will be 50%. You can mix % and positions

诠释孤独 2024-08-24 15:46:04

背景位置:右下角确实应该做您描述的事情。

如果您希望图像坚持使用 viewport 而不是文档的右下方,则必须添加background-atchment:fixed。 IE中存在问题,但是当在主体/HTML背景上使用时,这很好。

background-position: bottom right should indeed do what you describe.

If you want the image to stick to the bottom-right of the viewport rather than the document, you will have to add background-attachment: fixed. There are problems with this in IE, but when used on the main body/html background it's fine.

懒的傷心 2024-08-24 15:46:04

也许你忘了

background-position: absolute

maybe you forgot

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