0

Html

    <!DOCTYPE html>
    <html>
    <head>
        {%if title%}
        <title>Forum- {{title}}</title>
        {%else%}
        <title>Forum</title>
        {%endif%}
        <head>
            <!-- Required meta tags -->
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

            <!-- Bootstrap CSS -->
            <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" type="text/css" href="./Form.css">
            <title>Blog</title>
        </head>
        <body>

        <!-- Optional JavaScript -->
        <!-- jQuery first, then Popper.js, then Bootstrap JS -->
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    </head>
    <body>

    <nav class = "navbar navbar-expand bg-dark">
            <a class = "nav-item nav-link colora"  href="#">Home</a>
            <a class ="nav-item nav-link"  href="#">Posts</a>
    </nav>
    <div class = "container">
        {% block content %}{% endblock %}
    </div>


CSS

.colora a,.colora a:visited {
    color: rgb(255, 255, 250);
    text-decoration: none;
}

I'm trying to make the inside of the color white with the CSS file, unfortunately it doesn't seem to want to change even though I have specified it which should override the bootstrap. Thanks for taking your time to look at this problem!

2
  • Are you sure everything loaded correctly? Have you tried clearing your cache? Commented Apr 17, 2020 at 23:53
  • How do I do that? Clear my pycache? Commented Apr 17, 2020 at 23:56

3 Answers 3

1

Use !important attribute to override bootstrap. Also you have added the anchor tag wrong in css. The colora class is applied to anchor tag. However, your CSS denotes that find anchor tag inside colora class which is not present. Remove the anchor from the css and it will work. Below is your working code example.

.colora,.colora:visited {
    color: #fff !important;
    text-decoration: none !important;
}
 <!DOCTYPE html>
    <html>
    <head> 
        <head>
            <!-- Required meta tags -->
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

            <!-- Bootstrap CSS -->
            <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" type="text/css" href="./Form.css">
            <title>Blog</title>
             
        </head>
        <body>

        <!-- Optional JavaScript -->
        <!-- jQuery first, then Popper.js, then Bootstrap JS -->
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    </head>
    <body>

    <nav class = "navbar navbar-expand bg-dark">
            <a class = "nav-item nav-link colora"  href="#">Home</a>
            <a class ="nav-item nav-link colora"  href="#">Posts</a>
    </nav>
    <div class = "container">
        container 
    </div>

Sign up to request clarification or add additional context in comments.

8 Comments

Tried that before, didn't work. I don't think the problem is the CSS itself but it being not detected.
In which file are you adding that code. Also inspect element and check whether the css has been applied or not. If not, you are adding the style in wrong file.
I am doing that in the css file, but the element is not applied.
The thing is it may have been applied. However, the css file on your local is loaded first and bootstrap afterwards (due to cdn). In that case, bootstrap overrides the css. Also as pointed out by @Rob, please try the correct classname with !important attribute.
How can I load css after bootstrap?
|
0

Your css is referencing an a element that is the child of an element with a class of colora. There is no such element.

I think you want

a.colora,a.colora:visited {

but I can only guess.

a.colora,a.colora:visited {
    color: rgb(255, 255, 250);
    text-decoration: none;
}
<!DOCTYPE html>
    <html>
    <head>
        {%if title%}
        <title>Forum- {{title}}</title>
        {%else%}
        <title>Forum</title>
        {%endif%}
        <head>
            <!-- Required meta tags -->
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

            <!-- Bootstrap CSS -->
            <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" type="text/css" href="./Form.css">
            <title>Blog</title>
        </head>
        <body>

        <!-- Optional JavaScript -->
        <!-- jQuery first, then Popper.js, then Bootstrap JS -->
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    </head>
    <body>

    <nav class = "navbar navbar-expand bg-dark">
            <a class = "nav-item nav-link colora"  href="#">Home</a>
            <a class ="nav-item nav-link"  href="#">Posts</a>
    </nav>
    <div class = "container">
        {% block content %}{% endblock %}
    </div>

2 Comments

Thats a mistake that I made, but I don't think the class is what was causing it. As I have tried to use ids to debug yet it didn't work.
@MLee Please check the snippet. Is that what you are looking for?
0


<!DOCTYPE html>
<html>

<head>

    <title>Forum- home</title>

    <!-- Required meta tags -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <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" type="text/css" href="static/stylesheets/style.css">
    <title>Blog</title>
</head>

<body>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
        crossorigin="anonymous"></script>


    <nav class="navbar navbar-expand bg-dark">
        <a class="nav-item nav-link colora" href="#">Home</a>
        <a class="nav-item nav-link" href="#">Posts</a>
    </nav>
    <div class="container">


        <h1>Blog 1</h1>
        <p>By Matthew Lee on April 20, 2018</p>
        <p>First Post</p>


    </div>
</body>

Got it working, the problem was apparently I needed to rename the static which I named template, to static. Also I had to specify the file location instead of using the url_for method. Don't know why it worked but that would be the finalized code.

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.