css
#part1 {
background: url("img/00.jpg") repeat 0 0;
}
#part1 {
background: url("../img/00.jpg") repeat 0 0;
}
#part1 {
background-image: url("../img/00.jpg") repeat 0 0;
}
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>hello there</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header></header>
<div id="part1">hello there</div>
<footer></footer>
</body>
</html>
但是背景图片仍然没有显示...除了白色背景。任何人都可以提供帮助....我将图像存储在名为img的文件夹中
答案 0 :(得分:1)
在您的代码示例中,您使用3种不同的CSS规则来定位相同的元素。因此,只应用最后一条规则,因为它将覆盖另一条规则。
确保根据文件结构定义图像的正确路径。
#part1 {
background: url("http://patcreator.appspot.com/imgs/textures/light/light-texture-01.jpg") repeat 0 0;
}
<div id="part1">hello there</div>
答案 1 :(得分:-2)
要查看至少宽度应该具有的背景:100px;和身高:100px;试试这个
#part1{
background: url("img/00.jpg") repeat 0 0;
min-height:100px;
}
如果找不到图像,还要检查浏览器控制台!