我正在为学校编程班创建一个网站,但是CSS不会显示在我的主页上方,我创建CSS的模式也没有改变,到目前为止,我班的5个人已经检查过,并且不知道原因
主页
<head>
<link rel= "stylesheet" href="css1.css">
<meta charset = "utf-8">
<meta name= "keywords" content= "photo">
<title> "trash" </title>
</head>
<body bgcolor="#F5F6E9">
<div class="header">
<div class="container">
<div class="logo">
<h1><a href="index.html">LEGALIZE RANCH</h1>
</div>
<div class= "nav">
<ul>
<li><a href="index.html">RANCH!</a></li>
<li><a href="why.html">WHY?????</a></li>
<li><a href="brotendonation.html">BROTENDO NATION</a></li>
</ul>
</div>
</div>
</div>
<div class= "mainpart">
<div class="statement">
<p>
WHATS UP BROTENDOS
</p>
</div>
<div class= "god">
<center> <img src= "god.png" alt="ranch dude"> </center>
</div>
<div class= "statement2">
<p>
RANCH IS THE #1 MOST RARE RESOURCE EVER!!!! THAT MEANS OUR GOVERNMENT IS LIMITING IT FOR DUDES LIKE THIS!!!!!
</p>
<p>
THIS NEEDS TO BE ADDRESSED AT THE NINTENDO CONVENTION!!!!!
</p>
</div>
<div class= birdup>
<center><img src= "birdup.jpg" alt= "bir ddup"></center>
</div>
</body>
的CSS
body {
width: 100%;
margin : auto;
}
.container {
width: 960px:
margin: 0 auto:
}
.header {
background: #94DD6E;
height: 100px;
width: 100%;
top: 0;
position: fixed;
}
.logo {
float: left;
font-family: "Helvetica";
font-size: 15px;
margin-left:15px;
padding-top:10px;
}
a {
text-decoration: none;
color: #fff
}
li {
list-style: none;
float: left;
margin-left: 15px;
padding-top: 15px;
font-family: Arial, Helvetica, sans-serif;
margin-right: 15px;
}
.nav {
float: right;
padding-top: 10px;
}
.content {
background: #e7e8e1;
}
.statement {
padding-top: 100px;
text-align: center;
font-family: "Helvetica";
font-size: 25px;
}
.statement2 {
text-align: center;
.god {
text-align: center;
}
.pimplepete {
margin-top: 50%;
text-align: center;
color: orange;
}
.mainpart {
background-color: #F5F6E9;
}
.video {
padding-top: 25px;
}
.donation {
text-align: center;
font-family: "Papyrus";
font-size: 50px;
}
CSS无法使用的页面
<!doctype html>
<head>
<link rel= "stylesheet" href="css1.css">
<meta charset = "utf-8">
<meta name= "keywords" content= "photo">
<title> "trash" </title>
</head>
<body bgcolor="#F5F6E9">
<div class="header">
<div class="container">
<div class="logo">
<h1><a href="index.html">LEGALIZE RANCH</h1>
</div>
<div class= "nav">
<ul>
<li><a href="index.html">RANCH!</a></li>
<li><a href="why.html">WHY?????</a></li>
<li><a href="brotendonation.html">BROTENDO NATION</a></li>
</ul>
</div>
</div>
</div>
<div class= "video">
<center>
<iframe width="640" height="360" src="https://www.youtube.com/embed/0V7FGCtnoJo" frameborder="0" allowfullscreen></iframe>
</center>
</div>
<div class= "donation">
<p>
OUR MOVEMENT IS GROWING!!! SPORT SOME <i>RANCHY</i> MERCH
</p>
<p>
<a href= "http://legalizeranch.com/"> LEGAL RANCH MERCH </a>
</p>
</div>
</body>
不用担心,我知道格式不好。
最佳答案
您的CSS相对链接。
<link rel= "stylesheet" href="css1.css">
如果您的其他页面可能位于不同的文件夹中-文件夹中的
css1.css
文件旁边也没有html
,则它将无法理解对css1.css
的引用。如果要通过URL而不是文件系统访问站点,请尝试添加一个斜杠
/css1.css
,并且css
位于Web根目录中。如果要通过文件系统加载页面,请基于调用它的文件来调整对css的引用。您可以通过将其称为
../css1.css
来遍历某个级别。为了进一步说明,给定一个类似以下的文件系统:
public_html/
- index.html
- css1.css
- about/
- index.html
public_html/index.html
了解css1.css
,因为它们位于同一目录中。但是,在
public_html/about/index.html
中,如果<link>
标记引用css1.css
,则浏览器将查找名为public_html/about/css1.css
的文件,我想这个文件不存在。