0

I am making a web app in flask and use bootstrap for my front end. The external CSS file is located on /static of the application. The problem is the properties in the external CSS do not apply to the elements.

form.html

<head>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

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

form.html

<div class="jumbotron">
    <div class= "container">
        <h1>Application</h1>
    </div>  
</div>

style.css

.jumbotron {
    background-color: #191970;
    height: 100px;  
}
2
  • Do you see any errors in your browser console? Commented Mar 9, 2017 at 23:44
  • @DavidG No, no errors on the browser console! Commented Mar 9, 2017 at 23:54

2 Answers 2

0

(I can't comment yet so...) From Configuring Flask to correctly load Bootstrap js and css files

Try using:

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

The pattern they said here is:

{{ url_for('static', filename='path/inside/the/static/directory') }}
Sign up to request clarification or add additional context in comments.

Comments

0

Try solving in this way:

<head>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

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

</head>

assuming you have a folder "stylesheets" located inside the static folder, which contains the file style.css

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.