字体@font-face使用方法

字体@font-face

font-face使用方法:

@font-face{
  font-family:webfont;
  src:url('font/字体 名称.otf')format("opentype")
  };

属性值:

font-family:设置文本的字体名称;

font-style : 设置文本的样式; 

               属性值:normal默认值 italic斜体 oblique倾斜体 inherit从父元素继承

font-variant : 设置文本是否大小写;

               属性值:normal默认值 small-caps使用小型大写字母 inherit继承父级元素

font-weight:设置文本的粗细;

               属性值:normal默认值 bold使用粗体 bolder更粗的字体 lighter使用更细的字体

               100—900从细字体到粗的值必须是100的倍数,其中400等于normal,700等同于bold

font-stretch:设置文本是否横向的拉伸变形;

                属性值:

                normal正常文字的宽度
                narrower把收缩比例设置为更进一步的收缩值
                ultra-condensed比正常文字宽度窄4个基数
                extra-condensed比正常文字宽度窄3个基数
                condensed比正常文字的宽度窄2个基数
                semi-condensed比正常文字的宽度窄1个基数
                semi-expanded比正常文字的宽度宽1个基数
                expanded比正常文字的宽度宽2个基数
                extra-expanded比正常文字的宽度宽3个基数

                ultra-expanded比正常文字的宽度宽4个基数

font-size:设置文本字体的大小;

src:设置自定义字体的相对路径或者绝对路径  注意:此属性只能在@font-face规则内使用


在页面上显示服务器端的字体

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>在页面上显示服务器端的字体和@font-face</title>
    <style>
        /*设置下载好的字体*/
        @font-face {
            font-family: Webdings;
            src: url("NotoSansHans-Black.otf");
        }
        h1{
            font-family: Webdings;
        }
        @font-face {
            font-family: Webdings;
            font-style: italic;
            src: url("NotoSansHans-Black.otf");
        }
        h2{
            font-family: Webdings;
            font-style: italic;
        }
        /*设置本地的字体*/
        @font-face {
            font-family: Arial;
            src: local('Arial');
        }
        h3{
            font-family: Arial;
        }
    </style>
</head>
<body>
<h1>在页面上显示服务器端的字体和@font-face</h1>
<h2>在页面上显示服务器端的字体和@font-face</h2>
<h3>在页面上显示服务器端的字体和@font-face</h3>
</body>
</html>

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值