Css 背景不适用于div
我有以下HTML:Css 背景不适用于div,css,html,background-image,Css,Html,Background Image,我有以下HTML: <html> <head> <title> Think in a NEW BOX. </title> <link rel="stylesheet" type="text/css" href="styles/default.css" /> </head> <body onload="">
<html>
<head>
<title>
Think in a NEW BOX.
</title>
<link rel="stylesheet" type="text/css" href="styles/default.css" />
</head>
<body onload="">
<div id="content">
<div id="header">
<img src="images/title-1.png" /><img src="images/title-2a.png" /><img src="images/title-3.png" /></div><div id="fcontent">
hi
hi
</div>
</div>
</body>
</html>
我的背景没有显示出来,这是为什么
以下是所有CSS,以防问题可能出现在上面的CSS片段中,但是:
html, body {
background-color:black;
font-family:"arial bold";
overflow:auto;
text-align: center;
display: inline-block;
color:white;
}
div#content {
width:792px;
height:100%;
padding:0px;
}
div#header {
height:216px;
width:100%;
padding:0px;
margin-bottom:0px;
}
div#fcontent{
background-image:url('images/forground.png');
width:100%;
padding:0px;
margin-top:0px;
background-repeat:repeat-y;
}
* {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
我没有看到ID为fcontent的DIV可能是第一个问题。我没有看到ID为fcontent的DIV可能是第一个问题。请记住,图像的路径是相对于CSS文件的,因此如果CSS文件位于styles文件夹等中,当前请求的图像必须位于/styles/images/forgfround.png中 如果您将url的位置更改为绝对url,例如从根目录更改,则可以避免此类问题
url('/images/forground.png');
或者,您可能希望跳出当前文件夹,然后跳入图像文件夹:
url('../images/forground.png');
希望thant能有所帮助。请记住,图像的路径是相对于CSS文件的,因此如果您的CSS文件位于styles文件夹等中,则当前请求的图像必须位于/styles/images/forgfround.png中 如果您将url的位置更改为绝对url,例如从根目录更改,则可以避免此类问题
url('/images/forground.png');
或者,您可能希望跳出当前文件夹,然后跳入图像文件夹:
url('../images/forground.png');
希望thant能帮上忙。我刚刚粘贴了你的代码,它在chrome和firefox中对我有效
确保图像路径正确,您可能需要尝试设置高度。我刚刚粘贴了您的代码,它在chrome和firefox中适用
确保图像路径正确,您可能需要尝试设置高度。请注意,这是根路径:
url('/images/forground.png');
始终参考:www.yoursite.com/images/forgfround.png
这是相对路径,通常应使用:
url('images/forground.png');
url('../images/forground.png');
有关更多信息,请查看此线程:请注意,这是根路径:
url('/images/forground.png');
始终参考:www.yoursite.com/images/forgfround.png
这是相对路径,通常应使用:
url('images/forground.png');
url('../images/forground.png');
有关更多信息,您可以查看此线程:我的意思是,前台确实有一个e作为起点:将最小高度添加到fcontent并查看其是否有效:是否还有doctype?问题:指定背景颜色时背景是否显示?一种猜测可能是图像路径错误或不存在。文件名forground.png可能正确,但也可能不正确。当你使用背景色而不是背景图像时会发生什么?我的意思是,前景中确实有一个e将最小高度添加到fcontent并查看其是否有效:是否还有doctype?问题:指定背景颜色时背景是否显示?一种猜测可能是图像路径错误或不存在。文件名forground.png可能正确,但也可能不正确。当你使用背景颜色而不是背景图像时会发生什么?我从来没有想到会出现这个问题。我总是在同一个文件中使用CSS,这是我第一次使用外部CSS文件。非常感谢!我从来没有想到这会是个问题。我总是在同一个文件中使用CSS,这是我第一次使用外部CSS文件。非常感谢!是的,我必须把它们首尾相连,以消除IE喜欢的微小间距。是的,我必须把它们首尾相连,以消除IE喜欢的微小间距。