I'm using Flask and Bootstrap. I'm trying to combine my own custom CSS with some Bootstrap classes, and while I can apply Bootstrap classes to elements just fine, when I try to apply my own custom CSS, it doesn't always work. For example, I apply Bootstrap's text-center
to a div, and it works. I then try to apply some custom CSS and either nothing happens, or only part of my CSS is applied. For example, color: red
works but font-size: 100px
does nothing.
This is driving me absolutely insane, and I've tried everything. My CSS loads after the Bootstrap CDN, and I'm using url_for
in Flask to access the CSS file. I've also tried using !important
but this does nothing. I don't know what else to try.
Importing CSS stuff in my base template:
<head>
{% block head %}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"/>
{% endblock %}
</head>
In this next snippet, the Bootstrap classes all work. However, when I try to test some custom CSS with the red
class, things start going wrong. The color: red
property from my custom CSS works, but the font size change does not. I'm also not able to do anything custom with the image.
{% extends "base.html" %}
{% block content %}
<div class="header">
<header class="text-center">
<div>
<img src="{{ logo }}" class="img-fluid">
</div>
<div>
<p class="red">Text here.</p>
<p>More text.</p>
</div>
<div class="buttons">
<a href="{{url_for('about')}}" class="btn btn-secondary btn-lg active" role="button" aria-pressed="true">Link</a>
</div>
</header>
</div>
{% endblock %}
A bit of custom CSS
.red {
color: red;
font-size: 100px;
}