移动身体背景图像(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; }更多推荐
发布评论