2012-07-22 34 views
3

我希望我的背景DIV能够随时填充整个浏览器窗口。我在背景的顶部有一个DIV,它以我想要的方式移动,我有按百分比设置的定位。当我缩小时,两个DIV一起移动,创建背景颜色的曝光。这里是我的地盘:即使使用缩放也能填充浏览器窗口的DIV

http://search.officesupplycentral.org/details.html

这里是我怎么想我的DIV发挥作用的例子:

http://fab.com/

任何帮助将不胜感激!

吉姆

+0

你尝试把身体的“背景图像”属性? V – vellvisher 2012-07-23 07:02:44

+0

放入正文。 background:url('image.jpg')fixed; background-size:100%; – kakarott 2012-08-08 06:17:46

回答

0

fab.com使用一种特殊的做法,很容易看到,如果你只是检查站点的代码。

它设置背景的HTML标签<html style="background-image: url(//s3.amazonaws.com/static.fab.com/relaunch/fab-daily-design-for-everyone-8.jpg);">并设置以下值,它在CSS文件:

html{ 
    background-repeat: no-repeat; 
    background-attachment: fixed; 
    background-position: center center; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 

它然后设置背景<body>透明的CSS:

body{ 
    background: transparent; 
} 

我的教育猜测没有进一步研究这一点,因为图像被设置为<html>标记的背景,并且背景大小设置为覆盖,所以在页面放大或缩小时不处理它。