jinglei
jinglei

Reputation: 3353

external css file doesn't work in Flask framework

I'm trying to use an external css file in my html file. At first I used bootstrap framework and it works well. However, when I tried to customize the web page by adding a customized css file, it doesn't work at all! Here is my code:

    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="custom.css" type="text/css">

custom.css:

body{
background-color: #9acfea;}

Here I just want to change the background color.

'custom.css' is under the same path with the HTML file. Also, I've tried to only apply 'custom.css', so I create a new HTML file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="custom.css" type="text/css"/>
</head>
<body>
    hello
</body>
</html>

It doesn't work either. I'm confused. Why the bootstrap css file works perfect but the customized file doesn't? By the way, I'm using the Flask framework, but I don't think it matters. Any suggestions would be appreciate!

Upvotes: 4

Views: 1623

Answers (1)

edil3ra
edil3ra

Reputation: 21

<link href="{{ url_for('static', filename='custom.css') }}" rel="stylesheet"/>

Upvotes: 2

Related Questions