gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 13:33:11 25 4
gpt4 key购买 nike

我已经仔细检查了我的 URL 和文件名,但我似乎无法显示图像。为什么会这样?这是我的代码(注意 <p> 在 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 guarantee: 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>

这是那部分的 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;
}

最佳答案

试试这个:

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

如果没有 ../,它会在您的样式表文件夹中寻找一个不存在的图像文件夹。所以你必须回到images文件夹所在的目录。

编辑:您还可以像这样缩短您的 CSS 样式:

.guarantee{
background: #a7cece url(../images/background.gif);
border: 1px solid black;
}

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com