首页 文章

WebFont @ font-face定义serif / sans-serif / monospace

提问于
浏览
4

我在我的网站上使用了很多网页字体,现在我想添加新的字体系列,它有serif / sans-serif / monospace类型的字体 . 我的部分css:

@font-face {
    font-family: 'DejaVu', sans-serif;
    font-weight: 400;
    font-style: normal;
    src: url(dejavu/DejaVuSans.ttf)
}
@font-face {
    font-family: 'DejaVu', monospace;
    font-weight: 400;
    font-style: normal;
    src: url(dejavu/DejaVuSansMono.ttf);
}
@font-face {
    font-family: 'DejaVu', serif;
    font-weight: 400;
    font-style: normal;
    src: url(dejavu/DejaVuSerif.ttf);
}

但它不起作用(在css控制台中我看到错误:font-family的值不好) . 有没有办法让它只使用一个字体名称 .

我知道我可以将font-family名称改为:'DejaVu Serif',但我不想 .

1 回答

  • 2

    答案是否定的,唯一的方法是更改 font-family 名称以包含字体定义 .

    您可以设置 font-stylefont-weight 并使用它们来选择 font-face ,但不能堆叠 font-face 系列 .

相关问题