【发布时间】:2021-12-17 13:41:24
【问题描述】:
我在 C:\xampp\htdocs\area 中有 3 个文件。它们是index.php、styles.css 和result.php。虽然 index.php 中的样式可以正常工作,但在 result.php 中,它不起作用。
在styles.css 中,<span> 和 <h1> 标记的样式为 Poppins Black 和 Medium:
h1#font-custom {
font-family: "Poppins Black" !important; /* This h1 tag is styled. Note: the !important
property is used to override the custom-body class which styles the elements inside the
body to be Poppins Medium */
}
span#font {
font-family: "Poppins SemiBold" !important; /* The span tag is also styled */
}
在 index.php 中,Poppins 工作正常,但在 result.php 中,它不显示。
在result.php 中,HTML 看起来不错:
<!DOCTYPE html>
<html>
<head>
<title>Result</title>
<link href="styles.css" type="text/css" rel="stylesheet">
</head>
<body class="custom-body">
<?php
$height = $_GET['height'];
$width = $_GET['width'];
$area = $height * $width;
echo '<span id="font-custom extra-big">The area is ',$area,'.</span>';
echo '<br><br>';
echo '<span id="font-custom extra-big"><a href="index.php">Go back</a></span>';
?>
</body>
</html>
请帮忙!
【问题讨论】:
-
字体在哪里存储/获取?
-
index.php 中是否有任何额外的 css 导入?还有
span#font不匹配<span id="font-custom extra-big"> -
您正在为 h1 使用字体自定义 id,但在 span 中应用。将 span id 更改为字体并尝试其工作与否
-
另外,不要对同一页面中的多个元素使用相同的 id。 CSS 确实有效。但这是一个不好的做法。改用类
-
@Skully,字体存放在C:\Users\Name\AppData\Local\Microsoft\Windows\Fonts\POPPINS-BLACK.ttf,POPPINS-SEMIBOLD.ttf