2016-03-23 104 views
0

我希望將圖片作爲我的網站的背景,但無法更改圖片的大小。有沒有什麼辦法可以改變圖片的大小以適合我的網站?如何更改圖片背景的大小

P.S. 這是代碼中,我用它來顯示我的照片

body { 
    background-image: url('images/lvl1.jpg'); 

} 
+0

嘗試,讓'背景大小:cover'屬性,你的'body'標籤 –

回答

1

你可以做到這一點:

background-size: 100% 100%; 

background-size: contain; 
0

可以使用background-size屬性指定的大小你的背景圖片。

+1

雖然此鏈接可以回答這個問題,最好是包括這裏的答案的基本部分,並提供參考鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 - [來自評論](/ review/low-quality-posts/11740298) –

+0

@ Magicprog.fr謝謝。我會考慮這個。 –

0

使用的背景大小屬性:

body{ 
    background: url("images/lvl1.jpg"); 
    background-size: 100% 100%; 
    background-repeat: no-repeat; 
} 
0

這將有助於填補與背景。

body { 
    background-image: url('images/lvl1.jpg'); 
    -webkit-background-size: cover; 
    background-size: cover; 
} 
0

使用background-size: cover;

背景大小的CSS屬性指定的背景圖像的大小。圖像的大小可以完全限制或僅部分地保留其內在比例。

Here is the link for reference

html, 
 
body { 
 
    position: relative; 
 
    height: 100%; 
 
} 
 

 
body { 
 
    background-image: url(https://www.planwallpaper.com/static/images/bicycle-1280x720.jpg); 
 
    background-size: cover; 
 
    background-repeat: no-repeat; 
 
    background-position: center; 
 
}