我有以下HTML:背景不工作的一個div
<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:
div#fcontent{
background-image:url('images/forground.png');
width:100%;
padding:0px;
margin-top:0px;
background-repeat:repeat-y;
}
我的背景沒有顯示出來,這是爲什麼?
這裏是所有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;
}
我的意思是,「前景」的確對初學者有一個「e」。 :) – pixelbobby 2011-05-19 17:17:24
添加一個最小高度到你的fcontent,看看它是否工作:)你也有一個文檔類型? – 2011-05-19 17:19:00
問題:當你指定背景顏色時,背景會顯示出來嗎?有人猜測你的圖像路徑是錯誤的或不存在的。 – 2011-05-19 17:19:39