【发布时间】:2015-03-27 17:23:34
【问题描述】:
我尝试了很多方法,但无法让这两个文档一起工作。我确信 CSS 文件与正确的文件名正确链接。在观看了下面有关编写博客的 YouTube 视频教程后,我正在尝试此操作。 https://www.youtube.com/watch?v=24QmGjcqIiw
这是 HTML:
<!doctype html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="new 1.css" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header">
</div>
<div id="content">
<div class="post">
<h1>Post Title</h1>
<p>Testing Testing 123...</p>
</div>
<div class="post">
<h1>Post Title</h1>
<p>Testing Testing 123...</p>
</div>
<div class="post">
<h1>Post Title</h1>
<p>Testing Testing 123...</p>
</div>
<div class="post">
<h1>Post Title</h1>
<p>Testing Testing 123...</p>
</div>
<div class="post">
<h1>Post Title</h1>
<p>Testing Testing 123...</p>
</div>
</div>
</div>
</body>
</html>
现在是 CSS:
*{
margin:0px;
padding:0px;
}
body{
background-color: #f0f0f0;
font-size:14px;
color:#000000;
}
wrapper{
width: 80px;
margin-left:auto;
margin-right:auto;
}
#header
{
background-color:#cZazqqcccccaccccc;
height:800px;
width: 100%;
margin-bottom:10px;
}
#.post
{
background-color:#ffffff;
padding: 5px;
border: 1px solid #cccccc;
margin-bottom:5px;
}
【问题讨论】:
-
尝试
new1.css而不是new 1.css。两个文件(.html 和 .css)需要在同一个文件夹中。 -
是的......空间肯定会把它扔掉。
-
除了 CSS 文件相对于您的 HTML 文件的位置之外,您的某些 CSS 是可疑的。例如,
#.post无效。#cZazqqcccccaccccc的标题背景颜色是一个奇怪的值.... -
谢谢,修正了错误。我注意到它在我编写的mac上完美运行,但是当我将它移到Windows机器上时,问题就出现了。文件位置和名称绝对正确。