所以有了 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/