【发布时间】:2016-03-02 17:05:41
【问题描述】:
我刚刚开始了一个非常简单的练习,我创建了一个简单的 html 文件和一个 css 文件(在 css 文件夹中),以便了解有关 Angularjs 的更多信息。 练习从创建这两个文件开始(所以还没有 Angularjs)。
由于某种原因,我的任何浏览器都没有呈现 css 文件。 在 Chrome 上,我检查了 index.html 文件,然后单击资源,Css 文件就在那里!但它不起作用。
我不知道该怎么做,但这似乎是一个非常愚蠢的错误。 我在几个地方读到它可能与一个名为 nginx.conf 的文件有关
index.html
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test Your Knowledge: Saturn</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div id="myQuizz">
</div>
</body>
</html>
css/style.css
body { background-color: #fff; padding: 20px; }
#myQuiz {
font-family: 'Roboto', sans-serif; font-size: 16px; font-weight: 400;
width: 650px; height: 650px;
position: relative;
overflow: hidden;
color: #fff;
background: #000 url(.../images/background.jpg) no-repeat 0px 0px;
}
#myQuiz h2 {font-size: 3em; margin: 0px; font-weight: 100;}
#myQuiz h3 {font-size: 2.4em; margin: 0px; font-weight: 100;}
#myQuiz p { margin: 0px 0px 14px 0px; }
#myQuiz .btn{
display: inline-block;
cursor: pointer;
background-color: #c04b01;
color: #fff;
text-decoration: none;
padding: 5px 15px;
border-radius: 6px;
}
/* Intro */
#myQuiz .intro { position: absolute; top: 225px; left: 40px; width: 550px;}
#myQuiz .intro p { margin: 0px 0px 40px 0px; }
【问题讨论】:
-
您的 HTML 没有内容(空 div),您希望看到什么?
-
它似乎设置了高度和宽度以及背景颜色,因此您至少应该看到颜色,除非它不在可视区域之外。我会尝试将 inline-block 更改为仅阻止以查看是否获得预期结果。
-
有一个错字:
myQuizzvs.myQuiz -
兄弟,检查你的html中
myQuizz和css中myQuiz的拼写 -
您的 HTML 是空的,当然您什么也看不到!尝试将
body规则更改为body { background-color: red; padding: 20px; },如果它是红色的,那么您的 CSS 正在工作。