我在 C:\xampp\htdocs\area 中有 3 個檔案。他們是index.php,styles.css和result.php。雖然樣式 inindex.php作業正常,但 inresult.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>
請幫忙!
uj5u.com熱心網友回復:
你說在 results.php 中的 HTML 看起來不錯。恐怕不行。
嘗試將生成的 HTML 通過驗證器,它會告訴您不能有多個font-customid - id 必須是唯一的。
此外,您正在span#fontCSS 中進行設定,但在您的 HTML 中沒有任何帶有 id 字體的跨度。
我認為您想使用一個類在各個地方設定字體。
<!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 class="font-custom extra-big">The area is ',$area,'.</span>';
echo '<br><br>';
echo '<span class="font-custom extra-big"><a href="index.php">Go back</a></span>';
?>
</body>
</html>
在你的 CSS 中:
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-custom {
font-family: "Poppins SemiBold" !important; /* The span tag is also styled */
}
請記住像我們對跨度所做的一樣,將任何 h1 元素更改為具有類而不是 id。
uj5u.com熱心網友回復:
您是否嘗試清除快取?通常,當我無法加載影像和其他內容時,我會清除快取。此外,您的課程font-custom-extra-big似乎與span#font. 此外,如果您希望檔案中的所有字體默認為某種字體,您可以撰寫:
body {
font-family: "Poppins Black";
}
或者
#font {
font-family: "Poppins Black"; /* Note that I didn't put the element name because it is better practice not to do so... */
}
最后,您也可以嘗試使用隱身模式,因為它基本上不會保存您的快取。
希望這是有幫助的!
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/346571.html
上一篇:顯示空結果的下拉選單
