4

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!

jinglei
  • 2,609
  • 6
  • 21
  • 39
  • add full path to CSS. See - bootstraps files use full path. – furas Jan 31 '16 at 10:05
  • and YES, it can have matter that you use Flask. It is not PHP. Flask can have HTML files in `templates` folder but browser see it as different folder. Flask use `route` to change this path. But it doesn't change paths for static files. – furas Jan 31 '16 at 10:11
  • read about [static files](http://flask.pocoo.org/docs/0.10/quickstart/#static-files) in Flask. – furas Jan 31 '16 at 10:13
  • @furas Thanks a lot! Your answer helps me perfectly! – jinglei Jan 31 '16 at 12:31

1 Answers1

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