我的css不工作,但没有错误



我使用的是vs代码我尝试过:
-删除除一个样式外的所有其他样式
-检查所有分号和标记
–使用另一个浏览器
,这些都不起作用。

如果你有一个合理的答案,请回复:)谢谢!

<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="/body_favicon.ico" type="image/x-icon"/>
<a class = "one" href = "/index.html">MAIN</a>
</head>
<body>
<p id="p1">Websites by Froggy Sites!</p>
<p id="p2">Nelson Mandela - The Promotion</p>
<style>
html {
background-color: #0096FF;
}
@font-face {
font-family: neonclubmusic_bold;
src: url(NEON CLUB MUSIC_bold.otf);
}
@font-face {
font-family: neonclubmusic;
src: url(NEON CLUB MUSIC.otf);
}
a.one:link, a.one:visited, a.one:active {
font-family: "neonclubmusic_bold";
font-size: 20px;
color: black;
text-decoration: none;
}
a.one:hover {
color: black;
font-size: 25px;
text-decoration: underline brown 5px;
}
.p1 {
font-family: "neonclubmusic_bold";
font-size: 30px;
text-align: center;
}
.p2 {    
font-family: "neonclubmuic";
font-size: 20px;
text-align: left;
}
</style>
</body>
</html>

您可能在未包含CSS的情况下或在错误的位置使用CSS。

尝试在body上方的head部分中使用instyle标记,或者创建一个名为index.css的新文件,并将此文件连接到代码。

如果使用外部版本。例如

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css" />
<title>My site</title>
</head>
<body>
Other HTML STUFF HERE
</body>
</html>

或者如果您使用style标签

<!DOCTYPE html>
<html lang="en">
<head>
<style>
all styling here
body {
margin: 0;
}
</style>
<title>My site</title>
</head>
<body>
All HTML HERE
</body>
</html>

您试图在使用:.p1时访问类名,但您的html似乎是以p1作为id设置的。要访问css中的id,您需要更改"quot;至"#&";。

前任#p1{…}而不是.p1{…}

  1. 如上所述,首先应该确保引用元素以正确的方式,如果你需要按类(".")或按Id("#")
  2. 我已经在HTML中为您的代码给出了一些标准顺序用于提高可读性的结构
  3. 还有一些打字错误和无效空格

检查以下代码:

<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="/body_favicon.ico" type="image/x-icon"/>
<style>
html {
background-color: #0096FF;
}
@font-face {
font-family: neonclubmusic_bold;
src: url(NEON/CLUB/MUSIC_bold.otf);
}
@font-face {
font-family: neonclubmusic;
src: url(NEON/CLUB/MUSIC.otf);
}
a.one:link, a.one:visited, a.one:active {
font-family: "neonclubmusic_bold";
font-size: 20px;
color: black;
text-decoration: none;
}
a.one:hover {
color: black;
font-size: 25px;
text-decoration: underline brown 5px;
}
.p1 {
font-family: "neonclubmusic_bold";
font-size: 30px;
text-align: center;
}
.p2 {    
font-family: "neonclubmuic";
font-size: 20px;
text-align: left;
}
</style>
<title>Main</title>
</head>
<body>
<a class="one" href="index.html">MAIN</a>
<p class="p1">Websites by Froggy Sites!</p>
<p class="p2">Nelson Mandela - The Promotion</p>
</body>
</html>

我把HTML和CSS放在一个单独的文件中,就像您最初的例子一样。