我有这个index.aspx页面没有从CSS加载图形。文本'Test'正在加载。
我做错了什么?
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="chinatownexperience.index" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="body-1">
<div id="topblank"><p>test</p>
</div>
</div>
<form id="form1" runat="server">
</form>
</body>
</html>
CSS:
html,
body {
margin:0;
padding:0;
color:#000;
background: #9c0000;
background: url('images/Chinatown-lgebg.png') left top;
}
#body-1 {
width: 880px; height: 1500px;
margin: 0px auto;
padding: 10px;
overflow:hidden;
}
#topblank {
float: left;
width: 880px;
height:266px;
background: url('images/WebsiteTop.png') repeat-y left top;
}
我一定错过了一些傻事?
答案 0 :(得分:1)
对于这个例子你可以从root寻址,不要像这样使用单人床
background:url(/yourProjectRoot/cssFolderNameOrFile.../yourImage.*)
答案 1 :(得分:0)
图像的路径必须相对于CSS文件的位置而不是HTML / ASP /任何文件。你应该指出图像的正确位置。
示例:
如果你使用这样的目录结构:
- root\
|- css\
|- images\
page.extension
然后CSS文件上的路径应为:
background: url('../images/whatever.png');
答案 2 :(得分:0)
您的路径需要相对于样式表,而不是根。
root
-css/styles.css
-images/
index.html
因此,如果你有上述结构,你需要在CSS
中使用它background: url('../images/your_image.png');
(值得注意的是CSS中的.htc文件应该有一个相对于root的路径。对于旧的浏览器修复很方便)