2015-05-09 104 views
0

我尝试添加使用以下的背景下,放在里面custom.css:CSS背景不工作

} 

body { 
background-image: url("img/background.jpg"); 
} 

custom.css是在文件夹中的HTML/CSS

background.jpg是在文件夹中HTML/img

我应该怎么做才能使背景有效?现在它并没有出现。

回答

0

这是因为您的'img'文件夹与'css'文件夹位于不同的目录中。

尝试

background-image: url("../img/background.jpg"); 
2

升了一级,使用..您的网址选择:

background-image: url("../img/background.jpg"); 

这将水平上去(到HTML文件夹),然后找到background.jpg文件中的img文件夹。

0

请使用:

body{ 
    background-image: url('../img/background.jpg'); 
}