【问题标题】:How to use font-face on a local server (xampp)?如何在本地服务器(xampp)上使用字体?
【发布时间】:2015-09-03 17:27:16
【问题描述】:

我正在尝试使用 font-face 和我计算机上的本地字体的自定义字体。

我将 XAMPP 用于本地服务器,将 Dreamweaver 用作 IDE(不确定这是否重要,尽管我在那里“管理”了我的字体并添加了我正在尝试使用的字体)。

无论如何,当我尝试查看我的测试时,我不断从浏览器控制台收到以下“错误”:我正在尝试这个东西的 h1 元素上的字体系列的“未知属性名称”。

这是我写的一些代码,也许我有什么问题?

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Prueba: Importando Fuentes</title>

    <style type="text/css">

    @font-face
    {
        font-family: 'origami';
        src:url("http://localhost/Laboratorio%20de%20Pruebas/Mayo/Fonts/fonts/fonts/origami_making.ttf");           
        font-weight:normal;             
    }

    h1
    {
        font-familiy: 'origami', sans-serif;    
    }

    h2
    {
        font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;   
    }

    </style>
</head>

<body>

    <h1>ORIGAMI</h1>
    <h2>IMPACT</h2>

</body>
</html>

【问题讨论】:

    标签: css fonts xampp font-face


    【解决方案1】:

    我很确定您也需要origami_making.eot,并使用相对网址。例子

    @font-face {
     font-family: "Flaticon";
     src: url("flaticon.eot");
     src: url("flaticon.eot#iefix") format("embedded-opentype"),
     url("flaticon.woff") format("woff"),
     url("flaticon.ttf") format("truetype"),
     url("flaticon.svg") format("svg");
     font-weight: normal;
     font-style: normal;
    }
    

    【讨论】:

    • 谢谢。我刚刚尝试过,但我仍然得到相同的概率:o。将源更改为:src:url("origami_making.ttf") format("truetype"), url("origami_making.eot") format("embedded-opentype");
    • @EclipticalD 如果您以http://localhost/Laboratorio-de-Pruebas 访问您的网站,您的相对网址可能会有所不同,您的相对网址将是Mayo/Fonts/fonts/fonts/origami_making.ttf
    • 谢谢!你是对的 :) 刚刚修复它......我也有一个错字 -_-。
    猜你喜欢
    • 2014-04-11
    • 2017-05-13
    • 2011-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-26
    • 2014-05-14
    • 2014-07-09
    相关资源
    最近更新 更多