2013-04-11 155 views
0

我想要我的背景图像在浏览器窗口中完全填充。我试过css全屏幕背景

body {background:url(bg.jpg) fixed no-repeat 100%} 

但它没有覆盖整个屏幕。

回答

0

创建img标签的ID和以下格式化

#background { 
position: absolute; 
left: 0%; 
top: 0%; 
width: 100%; 
height: 100%; 
z-index: 1; 
} 
0

的CSS:

背景:网址(yourImage)固定不重复中心中心; background-size:cover;

修复and.stretch图片

4
css: 
background-size: cover; 

是你在找什么,因为我猜。 交叉borswer支持试试这个: CSS:

html { 
    background: url(images/bg.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 

来源: css tricks full page background