HTML和CSS背景图像未显示
我已经仔细检查了我的URL和文件名,但似乎无法显示图像。为什么会这样?这是我的代码请注意在body标签中,我没有添加完整的代码,我只添加了头部和具体问题HTML和CSS背景图像未显示,css,html,Css,Html,我已经仔细检查了我的URL和文件名,但似乎无法显示图像。为什么会这样?这是我的代码请注意在body标签中,我没有添加完整的代码,我只添加了头部和具体问题 <html> <head> <title>Head First Lounge.</title> <link type = "text/css" rel = "stylesheet" href = "stylesheet/s
<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看起来不错
您的问题在于URL本身。你可能是说:
background-image: url(../images/background.gif);
由于您使用的是相对路径,并且样式表位于“样式表/”目录中,因此您的代码让浏览器查找“样式表/images/background.gif”,因为它是相对于样式表的,而不是相对于文档的。您的CSS看起来不错
您的问题在于URL本身。你可能是说:
background-image: url(../images/background.gif);
由于您使用的是相对路径,并且样式表位于“样式表/”目录中,因此您的代码让浏览器查找“样式表/images/background.gif”,因为它是相对于样式表的,而不是相对于文档的。请在URL之前尝试../。此外,如果您检查firebug中的background属性,您应该能够判断是否确实找到了URL
.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;
}
如果这不起作用,请尝试设置宽度、高度和显示块。在URL之前尝试../。此外,如果您检查firebug中的background属性,您应该能够判断是否确实找到了URL
.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;
}
如果该选项不起作用,请尝试设置宽度、高度和显示块。将高度和宽度设置为宽度,以便显示背景图像。将高度和宽度设置为宽度,以便显示背景图像。检查以确保在“url”功能中使用的路径正确,然后使用“background size”属性可减小图像的大小,因为尺寸过大的图像总是会产生这种副作用,因此可能会使用“background position:cover”在图标中展开图像。检查以确保“url”函数中使用的路径正确,然后使用“background size”属性可减小图像的大小,因为尺寸过大的图像总是会产生这种副作用,而且可能会使用“背景位置:封面”在其con中传播图像您的代码对我有用。看见但是,我建议当你指定背景图像时,你也应该添加“背景位置”,“背景重复”。你的代码对我有用。看见但是,我建议在指定背景图像时,还应添加“背景位置”、“背景重复”。