在HTML页面中添加额外的字体

时间:2019-04-27 09:06:41

标签: html css django

问题是如何将特定字体应用于整个页面?我在下面的示例中做到了,它不起作用。仅当我将其应用于确切的标签时才起作用,例如:

<p style="font-family: Palatino Linotype; src: url({% static "fonts/Palatino.ttf" %})">Description-{{ current_boat.boat_description }}</p>
        </div>
{%  load bootstrap4 %}
{% load static %}
{% load staticfiles %}
{%  load thumbnail %}

<html lang="en">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>Boat pdf</title>

     <style type="text/css">

    @font-face   {
        font-family: Palatino Linotype; src: url({% static "fonts/Arial.ttf" %});
    }
    body {
        font-family: "Palatino Linotype", Arial, sans-serif;
        color: #333333;
    }

    </style>
</head>
<body>


            <p style="font-family: Palatino Linotype; src: url({% static "fonts/Palatino.ttf" %})">Description-{{ current_boat.boat_description }}</p>
        </div>

        <div class="row">
            {% for instance in current_boat.images %}


                <a href=" {{ instance.boat_photo.url}}"> <img class="  ml-3" src="{% thumbnail instance.boat_photo "default"  %}"></a>

            {% endfor %}

        </div>


</body>
</html>




1 个答案:

答案 0 :(得分:1)

这可能是问题的原因

@font-face   {
    font-family: Palatino Linotype; src: url({% static "fonts/Arial.ttf" %});
}

尝试将其替换为以下

@font-face   {
    font-family: Palatino Linotype; 
    src: url({% static "fonts/Palatino.ttf" %});
}