【发布时间】:2015-12-08 18:41:58
【问题描述】:
我尝试使用不同的编辑器和 IDE(netbeans 和 Visual Studio 代码)以及不同的浏览器(firefox 开发人员版),但是,我似乎无法将 css 表应用于主 html 文件。 样式表编辑器说 html 文件没有附加样式表 这是html文件:
<!DOCTYPE html>
<html>
<head>
<title>The Animal Game</title>
<meta charset="utf-8"/>
<link href="animalgame.css" type="text/css" rel="stylsheet" />
<script src="animalgame.js" type="text/javascript"></script>
</head>
<body>
<h1>The Animal Game</h1>
<p>Think of an animal, then let me guess it!</p>
<div id="container">
<fieldset>
<legend>Questions</legend>
<p id="questions"></p>
</fieldset>
<fieldset id="answer">
<legend>Answer</legend>
<button id="yes">Yes</button>
<button id="no" >No</button>
</fieldset>
</div>
</body>
</html>
CSS 样式表:
body {
font: 12pt "Century Gothic", "Helvetica", "Arial", sans-serif;
}
button {
font-size: 20pt;
font-weight: bold;
margin: 15px auto;
}
#container{
margin: auto;
width: 520px;
}
fieldset {
background-color: #F0F0F0;
float: left;
height: 150px;
margin-right: 15px;
text-align: center;
}
h1, p {
text-align: center;
}
#questions {
font-size: 16pt;
text-align: center;
width: 300px;
}
编辑:问题解决了!有一个错字。谢谢大家的提示
【问题讨论】:
-
你的控制台有错误吗?
-
@George 没有显示错误
-
.html 和 .css 文件是否在同一个文件夹中?
-
给你的想法! 1.调出fiddler,清除缓存,刷新。由于大小写问题或其他原因,请确保正在读取 css 文件而不是 404。 2. 将 CSS 转储到文件本身,并确保它按您期望的方式工作。