【发布时间】:2021-12-22 08:55:55
【问题描述】:
这是我的 .html 文件的头部:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<link href="http://fakedomain.com/smilemachine/html.css" rel="stylesheet"/>
<title>Common Questions</title>
<script language="javascript">
function show(name) {
document.getElementById(name).style.display = 'block';
}
</script>
</head>
我的 html.css 文件确实在它应该在的地方。但我绝对没有任何样式。
好的,所以现在我只是尝试在我的机器上本地解决问题。这是头:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<link href="cover.css" rel="stylesheet" type="text/css"/>
<title>Common Questions</title>
<script language="javascript">
function show(name) {
document.getElementById(name).style.display = 'block';
}
</script>
</head>
现在是 css:
BODY {
font-size: 18pt;
color:#000fff;
font-family: Helvetica;
margin: 0 9 9 9;
}
table {
font-size: 8pt;
color:#525252;
font-family: Helvetica;
margin: 0px;
border-collapse: separate;
}
th {
font-size: 10pt;
text-align: left;
color:#550055;
font-family: Helvetica;
border-color: #999;
border-width: 0 0 1px 0;
border-style: dotted;
}
td {
font-size: 10pt;
text-align: left;
color:#550055;
font-family: Helvetica;
border-color: #999;
border-width: 0 0 1px 0;
border-style: dotted;
}
.left {
display:inline-block;
font-size: 10pt;
color:#990055;
font-family: Helvetica;
margin: 0 0 5 0;
}
.right {
display:inline-block;
font-size: 18pt;
font-weight: bold;
float: right;
color:#525252;
font-family: Helvetica;
margin: 0px;
}
.question {
display:inline-block;
font-size: 18pt;
font-weight: bold;
float: right;
color:#B452CD;
font-family: Helvetica;
margin: 0px;
}
好的,我已经取得了一些进展。萤火虫的建议非常好。我看到 CSS 文件的链接被读取为中文字符。这是 UTF 编码问题,所以我只是在文本编辑器中打开我的文件,然后将它们保存为 UTF-16。
但现在它从 css 文件中读取了错误的数据!我已经上传了下面的 css 文件,但在 firebug 中它显示了一个两个衬里。
【问题讨论】:
-
这可能没有帮助。但是,您有什么理由为您的 css 文件使用完整的 URL 吗?为什么不直接使用 /smilemachine/html.css?
-
我只是认为绝对网址会更确定。就像它可以保证工作一样。
-
恰恰相反 ;-) 相对 URL 将在更多情况下起作用。
-
你的css中的错字也会这样做;)