admin管理员组文章数量:1594753
本文主要介绍如何在网站中下载字体并将其应用于网页之上,以以下网址为例进行相关操作的说明。Google Fonts | 谷歌字体中文版 | GoogleFontsGoogle字体·中国,提供Google字体调试工具、Google字体在线预览功能,国内可以使用.Google字体解封,Google字体CDN,Google字体镜像,GoogleFonts,谷歌字体http://www.googlefonts/
1.进入网址后,选择所需字体,点击下载即可
2.解压文件至项目目录之中,文件名可自行修改
3.网页源代码如下,主要介绍该下载字体的两种使用方式
(1)给font-family赋值该字体的名称即可使用
(2)通过@font-face可自定义该字体的名称,需要使用时将font-family赋值为自定义的名称即可
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>下载字体的使用</title>
<style>
/* 第一种方式 */
.p1 {
font-family: 'Poiret One';
font-size: 24px;
}
/* 第二种方式 */
@font-face {
font-family: 'font_one';
src: url(./font1/PoiretOne-Regular.ttf);
}
.p2 {
font-family: 'font_one';
font-size: 24px;
}
</style>
</head>
<body>
<p class="p1">The sky was cloudless and of a deep dark blue.</p>
<p class="p2">She stared through the window at the stars.</p>
</body>
</html>
运行效果如下图所示:
版权声明:本文标题:HTML5+CSS3之字体的下载使用 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1728200457a1149308.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论