css中的整页背景没有出现

时间:2012-09-24 19:35:42

标签: css background-image

出于某种原因,我在css中的完整页面背景无效。我曾经做过一次,但效果很好,但现在我只得到了白色背景。这是我相关的css代码的一部分:

* {
margin: 0;
padding: 0;
}

/* render html5 elements as block */
header, footer, section, aside, nav, article {
display: block;
}

html {
    line-height: 1;
    color: #555;
    font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;
    font-size: 14px;
    background-image: url(file:///HD/Users/Barbra/Sites/HSMAI/images/vbcc_background.jpg) no-repeat center center     fixed; 
-webkit-background-size: cover;
- moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

/* layout */

#wrapper {
width: 960px;
margin: 0 auto;
background-image: linear-gradient(bottom, #86D1C7 5%, #A8BCFA 53%);
background-image: -o-linear-gradient(bottom, #86D1C7 5%, #A8BCFA 53%);
background-image: -moz-linear-gradient(bottom, #86D1C7 5%, #A8BCFA 53%);
background-image: -webkit-linear-gradient(bottom, #86D1C7 5%, #A8BCFA 53%);
background-image: -ms-linear-gradient(bottom, #86D1C7 5%, #A8BCFA 53%);

background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.05, #86D1C7),
color-stop(0.53, #A8BCFA)
);
border: 2px solid #333;
/* curved border radius */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
padding: 10px;
margin-top: 10px;
margin-bottom: 10px;
}

我确信所有文件都在正确的位置,并且所有链接都已正确指定。

3 个答案:

答案 0 :(得分:1)

background-image的值仅为图片的网址。 如果您输入任何其他值,则声明无效。

变化:

background-image: url(file:///HD/Users/Barbra/Sites/HSMAI/images/vbcc_background.jpg) no-repeat center center fixed;

background-image: url(file:///HD/Users/Barbra/Sites/HSMAI/images/vbcc_background.jpg)

background: url(file:///HD/Users/Barbra/Sites/HSMAI/images/vbcc_background.jpg) no-repeat center center fixed;

答案 1 :(得分:0)

将背景赋予body元素,它应该可以工作。

答案 2 :(得分:0)

background-image: url(file:///HD/Users/Barbra/Sites/HSMAI/images/vbcc_background.jpg) no-repeat center center     fixed;

应该是

background: url('///HD/Users/Barbra/Sites/HSMAI/images/vbcc_background.jpg') no-repeat center fixed;