html - 在 html 和 css 中使用特定字体

标签 html css font-face

<分区>

我有一个 html 和 css 代码。我想使用我下载的一种特殊字体,在搜索了一些之后,我写了下面的代码:

    <head>
        <style>
        @font-face
        {
            font-family: paraaminobenzoic;
            src: url('paraaminobenzoic.otf');
        }
        p.custom_font {font-family: paraaminobenzoic;}
        </style>
    </head>

它不起作用,我不知道为什么。特别是我不知道我是否在正确的位置添加了下面的代码。

p.custom_font {font-family: paraaminobenzoic;}

谁能帮忙注意到这个问题?

最佳答案

字体的正确格式应该是:

@font-face{ 
font-family: 'MyWebFont';
src: url('WebFont.eot');
src: url('WebFont.eot?iefix') format('eot'),
     url('WebFont.woff') format('woff'),
     url('WebFont.ttf') format('truetype'),
     url('WebFont.svg#webfont') format('svg');
}

TTF - 适用于除 IE 和 iPhone 以外的大多数浏览器。

EOT - 仅限 IE。

WOFF - 压缩的新兴标准。

SVG - iPhone/iPad。

看这里: http://www.fontspring.com/support/installing_webfonts/how-do-i-use-the-webfonts

关于html - 在 html 和 css 中使用特定字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20546885/

上一篇:CSS - 嵌套 anchor 标记链接

下一篇:html - 嵌套的 css 背景图像在 3 级后不会改变

相关文章:

javascript - 无法在 Chrome 上运行第一个 tracking.js 示例

javascript - 调整表格单元格/行的大小以适合新旋转的图像

jquery - 需要一个非常简单的工作文件 uploader

javascript - 将事件绑定(bind)到没有事件的 <label> 然后触发两次

html - 如何制作一个 div 以适应滚动隐藏的所有可用宽度?

html - Joomla - 样式类别博客文章内容

html - 语义 ui 左菜单占用太多空间

css - Chrome 开发者工具因使用特定字体而崩溃

css - 考虑到页面加载时间,使用本地字体文件或谷歌网络字体哪个更有效?

bootstrap-4 - 如何将字体添加到 Bootstrap 主题中