2016-03-23 53 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; 
 
}