Switching the color of the nav-link in Bootstrap

Struggling to change the color of my Bootstrap's nav-link to white with no success. Here is my code snippet:

<nav class="navbar navbar-light" style="background-color: #5E9DFE;">
    <a class="navbar-brand" href="/"><span class="yellow">Div</span><span class="plate">Aid</span> <span class="salmon">T</span><span class="green">asks</span></a>
    <button aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-target="#navbar" data-toggle="collapse" type="button">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbar">
        {% if session.user_id %}
             <ul class="navbar-nav mr-auto mt-2" id="add-del">
                 <li class="nav-item"><a class="nav-link" href="/add">Agregar</a></li>
                 <li class="nav-item"><a class="nav-link" href="/delete">Eliminar</a></li>
             </ul>
             <ul class="navbar-nav ml-auto mt-2">
                 <li class="nav-item"><a class="nav-link" href="/logout">Cerrar sesión</a></li>
             </ul>
        {% else %}
             <ul class="navbar-nav mr-auto mt-2" id="log-reg">
                  <li class="nav-item"><a class="nav-link" href="/register">Registro</a></li>
                  <li class="nav-item"><a class="nav-link" href="/login">Iniciar Sesión</a></li>
             </ul>
        {% endif %}
   </div>
</nav>

After reviewing previous responses and CSS Specificity Documentation, I attempted to make changes:

nav .navbar-nav mr-auto mt-2 .nav-item .navlink{
    color: #ffffff;
}

nav .navbar-nav mr-auto mt-2 .nav-item .navlink:hover{
    color: #e8e8e8;
}

However, something still seems amiss. Grateful for any assistance.

Answer №1

Your HTML structure is incorrect

Check out this revised code snippet:

section .container-fluid.mr-auto.mb-2 .row .col-lg-6{
    background-color: #f9f9f9;
}

If the issue persists, consider using !Crucial to override any existing styles

section .container-fluid.mr-auto.mb-2 .row .col-lg-6{
    background-color: #f9f9f9 !important;
}

Answer №2

.nav-link {
  color: red;
}

.nav-link:hover {
  color: green;
}
<nav class="navbar navbar-light" style="background-color: #5E9DFE;">
  <a class="navbar-brand" href="/"><span class="yellow">Div</span><span class="plate">Aid</span> <span class="salmon">T</span><span class="green">asks</span></a>
  <button aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-target="#navbar" data-toggle="collapse" type="button">
                <span class="navbar-toggler-icon"></span>
            </button>
  <div class="collapse navbar-collapse" id="navbar">
    {% if session.user_id %}
    <ul class="navbar-nav mr-auto mt-2" id="add-del">
      <li class="nav-item"><a class="nav-link" href="/add">Add</a></li>
      <li class="nav-item"><a class="nav-link" href="/delete">Delete</a></li>
    </ul>
    <ul class="navbar-nav ml-auto mt-2">
      <li class="nav-item"><a class="nav-link" href="/logout">Log Out</a></li>
    </ul>
    {% else %}
    <ul class="navbar-nav mr-auto mt-2" id="log-reg">
      <li class="nav-item"><a class="nav-link" href="/register">Register</a></li>
      <li class="nav-item"><a class="nav-link" href="/login">Login</a></li>
    </ul>
    {% endif %}
  </div>
</nav>

Answer №3

To change the color of the navigation links to white, update the CSS under the nav-link class

.nav-link {color: white;}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

VSCode - when indenting, spaces are added around strings

Currently, I am utilizing Vue 3 along with Prettier in VS Code. One issue I am encountering is that when a string is on its own line, it is formatted correctly to my liking. However, the problem arises when my browser in Dev Tools renders strings with extr ...

Discover the seamless method of transferring data from an HTML5 form to a PHP page for processing without the need to refresh the page or manually navigate to the PHP file

When creating a website, I encountered an issue with a form that requires the user to select three options from select elements and then click a search button to search the database. The problem is that PHP does not retrieve the form data unless the button ...

the dropdown menu toggle is not working as expected

My dropdown icon is not appearing and the menu options are not functioning properly. Despite trying to use a script to display the text when an option is clicked, it doesn't seem to be working. It appears that the toggle functionality is not working ...

Mastering the art of obtaining XPaths through Selenium WebDriver

While working on test automation for a section of Outlook Web App, I focused on checking a designated test mailbox that receives emails from our company. I needed to verify specific texts within an email using Assert, but encountered difficulty in identify ...

Is there a way to verify if an ID includes more than one word?

I am trying to target a specific div with a unique id in jQuery: <div id="picture_contents_12356_title"></div> The '12356' is autogenerated and must be included in the id. I need to create a jQuery selector that combines "picture_co ...

Is there a way to easily toggle a Material Checkbox in Angular with just one click?

Issue with Checkbox Functionality: In a Material Dialog Component, I have implemented several Material Checkboxes to serve as column filters for a table: <h1 mat-dialog-title>Filter</h1> <div mat-dialog-content> <ng-container *ng ...

The disappearance of the checkbox is not occurring when the text three is moved before the input tag

When I move text three before the input tag, the checkbox does not disappear when clicked for the third time. However, if I keep text three after the input tag, it works fine. Do you have any suggestions on how to fix this issue? I have included my code be ...

What is the best way to customize the look of the v-calendar component in Vue.js?

I've recently started a project that involves Vue.js, and I needed to create a datepicker for it. After some research, I opted to utilize the v-calendar package. The implementation of the component went smoothly and functioned as expected right out o ...

How can you assign a div ID to an image with a backlink included?

I need assistance in centering an image with a back link inside a div id, positioned 850px to the left. Additionally, I require another Div Id containing text centered on the same line within that same 850px space. Below is my CSS: #container3 > div { ...

Checkboxes display on a separate line when rendered inlines

I'm having an issue with the rendering of my checkbox in CSS. The checkbox is currently displaying on a separate line from the text, but I would like it to be inline with the rest of the content. For reference, here is the full CSS and HTML code: htt ...

Styling an HTML table with two columns: one column displaying an image, and the other column containing information related to the image

I have a concept that involves creating a table with 2 columns. The left column will feature an image, while the right column will display data about the image in 6 rows. ________________________________ | |_______________| | | ...

HTML5 header video with a subtle color palette

Is there a way to insert a muted video in the header that spans the full width but only has a height of 300px? The issue I am encountering is that when I decrease the height of the video, the width automatically decreases as well. However, what I want is ...

Looking for assistance with my website's navigation bar and logo

Looking for assistance in moving my navigation buttons to each side of the logo. As a beginner in web design and CSS, I've been struggling with this task. Essentially, I want the "home" and "about" buttons on the left side of the logo, 16px apart from ...

The form features a "Select all" button alongside a series of checkboxes for multiple-choice options

I am facing difficulties trying to get the "Select all" and "Remove all" buttons to function properly within my form. Whenever I remove the "[]" (array) from the name attribute of the checkboxes, the JavaScript code works perfectly fine. However, since I n ...

The successful execution of $.ajax does not occur

Starting out with ajax, I wanted to create a simple add operation. Here is the code that I came up with: HTML: <!doctype html> <html> <head> <title>Add two numbers</title> <meta content="text/html;charset=utf-8" h ...

Retrieve the index value within a given range

How do I retrieve the index number using PHP? foreach ($array as $index => $value) { // Use $index to access the index number } Is there a way to obtain the index number in Go language? {{ range .posts }} {{ index . }} {{ .Id }} {{ .Name}} ...

Styling elements conditionally in React JS using inline styles

If the status of this task is 'Completed', I would like to hide the button (similar to adding a display: none property). Code: <Button size="small" style={{display:this.state.task.status == "Completed" ? "none":""}} ...

Is it possible to submit a HTML5 form and have it displayed again on the same page?

Is it possible to simply reload the sidebar of a page containing an HTML5 form upon submission, or is it necessary to load a duplicate page with only the sidebar changed? I am unsure of how to tackle this situation; firstly, if it is achievable in this m ...

"Effortlessly move elements with HTML5 drag and drop functionality from either direction

I'm working on an application that requires Html5 Drag and Drop functionality, which is currently functioning well. However, in the app, there may be instances where a dropped item is no longer needed and I want to allow users to re-drag and drop it b ...

Tips for rearranging table columns using drag and drop in react js

I have been experimenting with various libraries to create a drag-and-drop feature for changing table columns order. Here is my current implementation: import React, { useState } from 'react'; import './list_de_tournees.css' const Table ...