我在将图像插入到项目中时遇到问题。当我运行该项目时,它仅显示一个损坏的图像图标。我尝试放置不同的图像,但相同。我也尝试过将整个路径插入src,尝试使用
header{
background-image: url("../project/picture.jpg");
}
和
<header id="header=background">
<div class="logo"></div>
</header>
#header-background{
width: 100%;
height: 100px;
background: url(picture.JPG);
}
插入时
<img src="picture.jpg" alt="where is the image">
它返回文本。
答案 0 :(得分:1)
您在标头ID中使用了错误的名称,必须使用header-background
而不是header=background
。示例:
#header-background{
width: 100%;
height: 100px;
background: url(picture.JPG);
}
<header id="header-background">
<div class="logo"></div>
</header>
或者您也可以使用以下代码,但请确保<div>
中包含某些内容。
header
{
background-image: url("picture.jpg");
}
<header id="header-background">
<div class="logo">Hello</div>
</header>