html - <div> 元素中不显示背景图片 - CSS/HTML

标签 html css

screenshot of the directory structure 我创建了一个 <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/

相关文章:

javascript - 如何使滚动条(-track)在 chrome 中透明?

python - python flask 的 html 选项卡拆分

html - React.renderToStaticMarkup 输出十六进制代码

html - 为什么我的页脚是这样显示的

android - 媒体查询仅被某些手机匹配

html - 导航栏与 Logo 对齐

javascript - 我想使用 particle.js 制作一个网站,但左侧导航栏动画不起作用

javascript - 用于 Mapbox 服务的响应式 iframe

jquery - 使用 packery.js 时在父 div 中居中多个 div

html - CSS 语法 : ".one.column" ".two.column", 我没看错吗?