簡體   English   中英

如何在 css 中制作調整大小的背景圖像?

[英]How do I make a resizing background image in css?

到目前為止我所擁有的是:

body {
    background-image: url("image file");
    background-size: cover;
    background-repeat: no-repeat;
}

我在下面找到了答案。

使用background-size:cover ,背景將根據其父元素的大小自動縮放以覆蓋整個事物。

在這種情況下,為了放大或縮小它,您可以在 body 元素上設置寬度和高度。

用這個:

background-size: 100% 100%;

水平和垂直拉伸:

background-size: 100% 100%;

水平拉伸(保持圖像比例):

background-size: 100%;
background-size: 100% auto; /* This is the same as above (included so you can see the similarities below). */

垂直拉伸(保持圖像比例):

background-size: auto 500px; /* If you use percentage (100%), you must set the height of the containing element. */

我終於找到了一個答案,我所要做的就是修改你的一個答案

body {background-image: url("image file");
background-size: 110% 130%;
background-repeat:no-repeat;

謝謝你的幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM