我在记事本上为一个带有 css 的 html 站点编写了这个示例代码,但这在 Mozilla(版本 49.0.etc)上不起作用,而在 IE、Chrome 和 Opera 上却起作用。如果我在 FF 上启动它,调试器会说“CSS 没有错误”,但它只显示 html 代码。 有人知道如何解决吗?
这里有我的站点在本地路径上的代码(html 和 CSS):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
http://www.w3.org/TR/html4/loose.dtd>
<html lang="it">
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="iso-8859-1">
<title>Site</title>
<style type="text/css">
</style>
<link href="C:/Users/Dean/Desktop/Site/File/file1.css" rel="stylesheet" media="all">
</head>
<body class="sub">
<div class="alt">
<h1>Text here</h1>
</div>
</body>
</html>
这里有 CSS 文件属性:
.sub{background-image:url("../image/bg.jpg");
background-repeat:no-repeat;
background-size:100% 100%;
background-attachment:fixed;
}
.alt {background-color:hotpink;
box-align:right;
border-radius:10px;
}
.set {font-size:12px;
color:white;
}
最佳答案
我假设这是因为您的样式表是通过非标准 file
协议(protocol)链接的(href="C:/Users/Dean/Desktop/Site/File/file1.css "
)。根据我的经验,Firefox 通常比其他浏览器更符合标准。
我假设这就是为什么您的示例在其他浏览器中有效,但在 FF 中无效的原因。尝试使用 HTTP 服务器提供您的样式表。
关于html - 为什么 Firefox 不会在没有错误消息的情况下启动 Css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40298117/