【发布时间】:2021-11-03 14:15:07
【问题描述】:
我正在学习 Flask,并且我有这个基本的 Web 应用程序。我正在使用 Bootstrap 5,我注意到如果我加载 Bootstrap 样式表,我的自定义 CSS 将不起作用(如果我删除 Bootstrap 样式表,它可以正常工作)。
我有这个文件夹结构:
flaskWebsite
|
|__pycache__
|
|templates
|index.html
...
|static
|
|main.css
|main.js
|venv
|
|app.py
以下是一些相关代码:
app.py
>@app.route("/")
def index():
return render_template('index.html')
index.html
<head>
<title>Home</title>
<!--Custom CSS-->
<link rel="stylesheet" href="{{url_for('static', filename='main.css')}}">
<!-- Latest compiled and minified Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
我尝试将 bootstrap.min.css(从 Bootstrap 下载)放入 static 文件夹,但没有改变。
谁能解释一下为什么会发生这种情况,我该如何解决?
【问题讨论】:
标签: python html css flask bootstrap-5