【发布时间】:2021-08-28 16:01:57
【问题描述】:
我有一个访问 style.css 文件的 .html 文件:
<html>
<head>
<link rel = "stylesheet" href = "../style.css"/>
</head>
<body>
<p>
This is it.
</p>
</body>
</html>
这是 style.css 文件:
GNU nano 4.8 /var/www/html/style.css
body {
margin: 0;
font-family: Arial;
text-align: center;
}
a {
font-size: 50px;
margin: 5px 10px 5px 0px;
}
h1 {
margin: 10px;
font-size: 100px;
}
p {
font-family: Arial;
font-size: 55px;
}
我知道 .html 文件正确链接到 .css 文件,因为文本居中对齐,字体大小为 80px,但字体系列不是 Arial,它是默认的 Linux Mint 字体。 如果我在 .html 文件中使用 标签,并更改字体系列,它会改变,但由于某种原因,在使用 .css 文件时它不会改变。
【问题讨论】:
-
这是您文件中的全部代码吗?
-
不,
标签里的代码不一样,还有一些标题,不过没关系
-
还有其他 CSS 吗?您可以尝试在 font-size 之后添加 !important(如 font-size: 80px !important;)吗?
-
哇,我刚刚打开了实际的网址,一切都有Arial字体,但是当我用本地IP(127.0.0.1)打开它时,它没有Arial字体。 (什么?)
-
我尝试在本地服务器上运行您的代码,它运行良好。正如你提到的,我用外部 CSS 尝试过,效果很好,我不太清楚你做错了什么