python - 将谷歌字体添加到 Flask

标签 python css fonts flask

所以有了 flask,我知道我可以用

添加 CSS
<link ... href="{{ url_for('static', filename='stylesheets/style.css') }}" />

但是如果我添加一个通常在 HTML 中看起来像的谷歌字体

<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>

我需要编辑/添加什么才能与 Flask 一起使用?

最佳答案

将 google 字体链接添加到您的 index.html 或您想要的任何页面,如下所示:

{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block styles %}
{{ super() }}
<link rel="stylesheet" href="{{ url_for('static', filename= 'mystyle.css') }}">
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>
{% endblock %}

然后,将 CSS 字体语句添加到您的自定义 CSS 文件(我的是 static/mysyle.css):

body {
    font-family: 'Open Sans Condensed', sans-serif;`
}

关于python - 将谷歌字体添加到 Flask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29375046/

相关文章:

html - 网页四面出现白线

javascript - 如何为 html 元素的填充设置动画

javascript - 保存字体文件以供离线查看

html - 图标大小不正确(字体很棒)

python - 在 python 中使用我的 unicode 字符串?

python - 使用 Pandas 将多列映射到单个数据框

python - 欧拉计划 19. 周日太多

javascript - 如何在 fullpage.js 中应用固定背景

css - 如何始终调整本身小于标准的字体大小?

python - 使用 pandas 解析 JSON 文档中的一个部分