[英]New classes don't work, but old classes work perfectly fine
When I create a new class and try to use it, it does not work.当我创建一个新的 class 并尝试使用它时,它不起作用。 Here is the CSS I am using:
这是我正在使用的 CSS:
/* NEW */
.Test {
color:purple;
}
/* OLD */
.TitleFont {
font-family: MiriamLibre-Regular;
color: white;
margin-left: auto;
margin-right: auto;
width: 8em;
}
As you can see, the class commented NEW is one one I just created, and the one commented OLD is the one I had created a while ago.如您所见,注释为 NEW 的 class 是我刚刚创建的一个,而注释为 OLD 的一个是我不久前创建的。 I can use the new class with a h1 tag like this:
我可以使用带有 h1 标签的新 class,如下所示:
<h1 class="Test">This is a test.</h1>
When I go to the page it does not show the purple it was supposed to show.当我 go 到页面时,它没有显示它应该显示的紫色。 (It does the same for anything, I just put color:purple; as an example)
(它对任何东西都一样,我只是把 color:purple; 作为例子)
Here is an image of it not working.这是它不起作用的图像。
I can replace the class used in the HTML with the old class like this:我可以用旧的 class 替换 HTML 中使用的 class,如下所示:
<h1 class="TitleFont">This is a test.</h1>
And it works perfectly fine.它工作得很好。 (All my other classes from a while ago work fine too.)
(我不久前的所有其他课程也都很好。)
You can see it working here.你可以看到它在这里工作。
How can I fix this?我怎样才能解决这个问题?
In HTML, you have this:在 HTML 中,你有这个:
<h1 class="Test">
So the class you use there is .test
所以你使用的 class 是
.test
But your CSS rule looks like this:但是您的 CSS 规则如下所示:
.TestClass {
color:purple;
}
That's for a class named .TestClass
(which you don't use in your HTML code...)这是一个名为 .TestClass 的
.TestClass
(您不在 HTML 代码中使用它......)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.