【发布时间】:2015-12-29 06:04:00
【问题描述】:
header 的 CSS 规则不适用于 Chrome 或 Firefox,但 section 可以,而且奇怪的是它们都适用于 JSFiddle。
html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="header">
<h1>Test</h1>
</div>
<div id="section">
<p>test</p>
</div>
</body>
</html>
style.css:
<style>
#header {
background-color: #f0fff0;
color: #262626;
text-align: center;
}
#section {
text-align: center;
}
</style>
【问题讨论】:
-
你在外部 CSS 文件中也有那些
<style>标签吗?为什么? -
为什么你的 CSS 文件有样式标签?没有 HTML 是 .css 文件。
-
您的样式表加载正确吗? (我是说不是)。在浏览器中打开页面。查看源代码。通常,样式表链接中的“style.css”变为可点击的(在查看源代码中)。点击链接。它加载吗?还是404?
-
@qwr 你有没有看到你的网络检查器控制台来识别任何明显的错误,例如你的 .css 文件中有 HTML:
<style>标签无效 -
@cale_b 它以纯文本形式加载
标签: javascript html css