在學習CSS時,我已經編寫了以下代碼以使用我放在本地硬盤上的Google字體。 如果將html文件保存在字體文件夾中,但該文件不能在不同的文件夾中工作,則該html文件將起作用。請注意, 我沒有通過任何服務器工作。將文件保存到另一個文件夾後,雙擊它。本地驅動器上的自定義字體不起作用
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Fonts</title>
<style>
@font-face {
font-family: 'Abel-regular';
src: url('file://G:/JavaPrgsJGD/fonts/Google-fonts/Abel/Abel-regular.ttf');
font-weight: normal;
font-style: normal;
}
</style>
<style type="text/css">
.ngs-h3 {font-family: 'Abel-regular'; font-size: 30px; color: green;}
.ngs-p {font-family: 'Abel-regular'; font-size: 20px; color: blue;}
</style>
<script>
</script>
</head>
<body>
<h3 class="ngs-h3">Technical assessment of a movie</h3>
<p class="ngs-p">
Many people see the movies and immediately after completion of the show, when asked by news channels,
they simply brush aside the movie saying, "It's a bogus movie" without realizing that what goes in for
bringing a movie to a cinema theatre for viewers, but of course, they have spent money and time to
watch a movie, they at least deserve a free opinion.
</p>
<p class="ngs-p">
However, this forum is not about personal likes and dislikes of down-to-earth movie-goer. This forum
is for students who are pursuing their technical studies in film industry. Therefore, let us concentrate
on technical aspects of a movie.
</p>
</body>
</html>
我做錯了嗎?請指導我,並在有和沒有服務器的情況下使用本地文件。 謝謝。 NG SHAIKH。
提供的CDN也許只是刪除'文件://'你的URL。 – Huelfe
當使用本地文件時,引用**從當前文件**開始(在你的情況下它是HTML文件)。從這個HTML文件中提到URL,而不是完整的路徑,包括G:/驅動器等。爲了得到一個清晰的圖片,你可以告訴你的HTML文件和字體文件放在哪裏('Abel-regular.ttf') –