我已经仔细检查了我的 URL 和文件名,但我似乎无法显示图像。为什么会这样呢?这是我的代码(注意<p>
在body标签里面,我没有添加完整的代码,我只添加了head和具体问题)。
<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文件夹所在的目录。
Edit:您还可以缩短 CSS 样式,如下所示:
.guarantee{
background: #a7cece url(../images/background.gif);
border: 1px solid black;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)