移动身体背景图像(Move body background image)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
移动身体背景图像(Move body background image)

我正在使用此CSS将图像放入<body> :

body { background: url('picture.png') no-repeat; background-size: contain; }

图像显示在浏览器窗口的顶部,但我需要将此图像放在顶部几个像素处。

我试过使用padding/margin-top: 20px; ,但它没有帮助我,图像仍然在浏览器窗口的顶部。

我怎样才能将这个背景图像的body标签从顶部向下移动几个像素?

注意:我需要在身体标记中显示图片。

I am using this CSS to put an image into the <body>:

body { background: url('picture.png') no-repeat; background-size: contain; }

The image is displayed at the top of the browser window, but I need to place this image a few pixels from the top.

I've tried using padding/margin-top: 20px;, but it didn't help me, the image is still at the top of the browser window.

How can I move this background image for the body tag a few pixels down from the top?

Note: I need to have the picture in the body tag.

最满意答案

您需要使用background-position 。

body { background: url('picture.png') no-repeat; background-position: 0 20px; background-size: contain; }

You need to use background-position instead.

body { background: url('picture.png') no-repeat; background-position: 0 20px; background-size: contain; }

更多推荐

本文发布于:2023-04-13 12:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/af7ba6816c14b237317088e802f7a64d.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   背景   身体   Move   background

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!