HTML5+CSS3之字体的下载使用

  本文主要介绍如何在网站中下载字体并将其应用于网页之上,以以下网址为例进行相关操作的说明。Google Fonts | 谷歌字体中文版 | GoogleFontsGoogle字体·中国,提供Google字体调试工具、Google字体在线预览功能,国内可以使用.Google字体解封,Google字体CDN,Google字体镜像,GoogleFonts,谷歌字体http://www.googlefonts.net/

 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>

运行效果如下图所示:

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值