Html CSS 的主体背景图像不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21351004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS' body background-image doesn't work
提问by Reinaldy
The image file (a1.jpg) exists and in the same folder. But it doesn't show up, only the font's color become white.
图像文件 (a1.jpg) 存在且位于同一文件夹中。但它没有出现,只有字体的颜色变成白色。
Anyone can explain me why and how to fix it?
任何人都可以解释我为什么以及如何解决它?
<style type="text/css">
p,h1,h2,h3,h4 {
font-family: Verdana, Geneva, sans-serif;
color: white;
}
a {
text-decoration: none;
}
body {
background-image: url('a1.jpg');
}
th,td {
font-family:Arial, Helvetica, sans-serif;
color:white;
}
</style>
回答by C Travel
If your title is right, you need to set a background color before the image.
It's very unclear what you are asking... Do you want to have a backrgound color and an image?
如果您的标题正确,则需要在图像之前设置背景颜色。
很不清楚你在问什么......你想要背景颜色和图像吗?
background: #ffffff;
background-image: url('a1.jpg');
回答by ralph.m
The image file (a1.jpg) is exist and in the same folder ...
The image file (a1.jpg) is exist and in the same folder ...
In whichfolder, though? The html page's folder, or the CSS file's folder? The path will only work if the image is in the same folder as the CSS file.
但是在哪个文件夹中?html 页面的文件夹,还是 CSS 文件的文件夹?该路径仅在图像与 CSS 文件位于同一文件夹中时才有效。
回答by Gad
the value of the background-image should be like this form and should be in the same folder:
background-image 的值应该是这样的形式并且应该在同一个文件夹中:
background-image:url(../img/1.jpg);