我不知道如何将CSS
文件链接到我的HTML
文件.
我正在使用Visual Studio Code、Python和Flask来完成这个任务
我的项目目录如下:
- templates
- home.html
- style.css
- app.py
home.html
<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Raleway:400, 600' rel='stylesheet' type='text/css'>
<link href='assets/style.css' rel='stylesheet' type='text/css'/>
</head>
<body>
...
</body>
style.css个
html, body {
margin: 0;
padding: 0;
}
header {
background-color: #333333;
position: fixed;
width: 100%;
z-index: 5;
}
h1 {
font-family: 'Times New Roman', Times, serif;
color:cadetblue
}
app.py
from flask import Flask, render_template
app = Flask(__name__, template_folder="templates")
@app.route("/home")
@app.route("/")
def index():
return render_template("home.html")
我试着使用模板文件夹,它没有工作
我试过了,没有使用模板文件夹,它不起作用.
不会引发错误,但页面就是没有CSS
样式,例如h1标签使用默认字体保持为黑色,而使用Times New Roman Font的标签应该为蓝色
任何帮助将不胜感激.🙂