我最近下载了html5样板,并试图很好地掌握如何将我的css代码合并到main.css of html5样板中。我需要知道如何将我的背景图像添加到我的页面中?
html {
background:url(Images/laptop.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}发布于 2014-06-26 02:10:30
试试这个:
body {
background-image:url(../Images/laptop.jpg) no-repeat center center fixed;
// rest of your code
}您的CSS文件应该在css文件夹中,图像应该在另一个文件夹中。因此,我在路径之前使用了../。
这里是对文件路径的简要描述:
./表示当前目录
../是指当前目录的父目录,而不是根目录。
/是根目录
myfile.text在当前目录中,./myfile.text也在
../myfile.text是您之上的一个级别,/myfile.text位于您的根目录中。
https://stackoverflow.com/questions/24421318
复制相似问题