2012-11-01 58 views

回答

0

试试这个:

.classname 
{ 
background: url(../images/background.jpg) no-repeat; 
background-position:center center; 
background-attachment:scroll; 
background-size:100% 100%; 
} 
+0

'{background-size:contains; '也适用。 – Nic

2

试试这个background-size:cover

body{ 
    background:url("myBgUrl"); 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
}​ 

more info

+0

非常推荐使用'background-size:cover'。对于不支持它的浏览器,您可以使用[polyfill](https://github.com/nsbingham/BackgroundSize)。 – koostudios

+1

完美rohit ..........和背景大小:封面支持,直到IE-9 ...... –

0

请使用一个,它将支持所有浏览器

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script> 
<script src="jquery.backstretch.min.js"></script> 

来电图像

jQuery(document).ready(function() 
    { 
    $.backstretch("path/to/image.jpg"); 

    }); 

你可以从这里 https://github.com/srobbin/jquery-backstretch

0
body 
{ 
background:url(/image/bg.jpg) repeat-x; 
} 

如果下载js文件不工作!

body 
{ 
background:url(/image/bg.jpg) repeat; 
} 

希望这可以帮助你。