我创建了一个 <div>
元素,我将在下面使用 css
<div>
风格元素。
#girls {
background-image: url("girl.gif");
}
这是我的 HTML <div>
元素(此元素包含在 index.html
页面中):
<div id="girls">
<p>
<b>Girls chat:</b> at the lounge, we're committed to providing you, our guest, with an exceptional
experience every time you visit. Whether you're just stopping by to check in on email over an elixir,
or are here for an out-of-the-ordinary dinner, you'll find our knowledgeable service staff pay attention to every
detail. If you're not fully satisfied, have a Blueberry Bliss Elixir on us.
</p>
</div>
但是当我加载索引页时,背景图像 (girl.gif) 没有显示。谁能帮我解决这个问题?
最佳答案
试试这个:
#girls {
background-image: url("../girl.gif");
}
我猜 css
位于 stylesheet
文件夹中,这就是为什么您需要上一层才能访问 girl.gif
,因此使用 ../
关于html - <div> 元素中不显示背景图片 - CSS/HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44126023/