css - HTML 和 CSS 背景图像未显示

标签 css html

我已经仔细检查了我的 URL 和文件名,但我似乎无法显示图像。为什么会这样?这是我的代码 注意

在 body 标签内,我没有添加完整的代码,我只添加了头部和具体问题。

<html>
  <head>
                <title>Head First Lounge.</title>

                <link type = "text/css" rel = "stylesheet" href = "stylesheet/style.css" media = "screen"/>
  </head>

    <p class = "guarantee">

                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>        Our guarantee: at the lounge, we're committed to providing you, 

这是那部分的 CSS 规则

    .guarantee{

        background-image: url(images/background.gif);
        font-family: "Geogia", "Times New Roman", Times, serif;
        border-color: black;
        border-width: 1px;
        border-style: solid;
        background-color: #a7cece;


padding: 25px;
    margin: 30px;
    line-height: 1.9em;
    font-style: italic;
    color: #444;
}

最佳答案

您的 CSS 看起来不错。

您的问题出在 URL 本身。你可能是说:

background-image: url(../images/background.gif);

由于您使用的是相对路径并且您的样式表位于“stylesheet/”目录中,因此您的代码让浏览器寻找“stylesheet/images/background.gif "因为它是相对于样式表的,而不是文档。

关于css - HTML 和 CSS 背景图像未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8839374/

相关文章:

javascript - 使用 jQuery select2 设置多个值

html - 当我应用 CSS 类时,该类已应用但类为空

php - 如何使用 body_class 将 CSS 类添加到 Wordpress 中的 body 标签

css - SASS url() 直接路径

html - 内容类型与 HTML 编码

python - 将 python 列表传递给 django 模板

css - 我是否需要将边框颜色指定为#value 和 rgba?

html - 分辨率之间的样式

jquery - 链接处于事件状态时保持悬停效果

css - 如何自动扩展绝对定位的 DIV