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

What is the best way to create a percentage glyphicon star icon that reflects a decimal average rating?

I have an average rating of 4.3 and I need to create a logic to display this as 4.3 stars (4 whole stars and the 5th star partially filled). The maximum rating is out of 5. Despite referring to examples on Stack Overflow and creating a JSFiddle, I am unabl ...

Refresh the content with an embedded iframe

I am attempting to update the body content by removing all existing content and inserting an iframe: function create_custom_iframe(target){ var iframe = document.createElement('iframe'); iframe.setAttribute('id', 'target_u ...

What is the best way to retrieve dynamic content from a .txt file and have it displayed on multiple HTML pages as they are loaded dynamically?

I have a file named 'm_data.txt' stored on the server that contains a continuous total of 77 (for instance). The total gets updated via a push.php page that writes to the .txt file. <!DOCTYPE html> <html> <head> <title> ...

CSS: The element's relative size causes the background image to vanish

I am facing an issue with displaying a background-image that is 800x480 pixels. The background image appears when the element has a fixed size, but not when the element has a relative size or a max-width. Functional CSS code: .audio-container, .settings- ...

Tips for inserting a rotated image using CSS

I've created the following code snippet. However, there is a new requirement stating that the image needs to be rotated by 180 degrees. How can I make this happen? #cell { background-image: url("../images/logo.PNG"); background-attachment: fixed; b ...

I'm having an issue with my Bootstrap tabs - they seem to be unresponsive when clicked

I've been working on a Bootstrap website and have run into some issues that I can't seem to resolve. One problem I encountered was with a set of tabs that were supposed to be interactive, but for some reason, they weren't working as expected ...

Assign a class to the "li" element containing an "a" tag with the specified href attribute

Is it possible to transform the "href" attribute of an element into a class or id like "li" for better css handling? <ul> <li><a href="#section3"><span class="fp-sr-only">due</span><span></span></a><d ...

How to add icons to HTML select options using Angular

Looking for a way to enhance my component that displays a list of accounts with not only the account number, but also the currency represented by an icon or image of a country flag. Here is my current component setup: <select name="drpAccounts" class= ...

How can I show the table row as an inner table row when the first field is identical?

<tr ng-model="check" ng-repeat="orderBook in orderBookDetails| orderBy: 'orderBook.no'" value='check=$scope.orderBookDetails.sowNo'> <td ng-if='check!=orderBook.no'>{{orderBook.no}}</td> <td>{{order ...

Using setInterval on a batch of freshly generated div elements

I am interested in creating a small website where I can display multiple clocks for various time zones. However, I have encountered an issue with the setInterval function. Below is the code snippet: function addClock () { $("#container").append('& ...

Is it not possible to change node labels in D3.js after clicking on a node?

After being inspired by this link, I successfully created a basic network visualization app using D3.js. The app reads node names from a textarea on an HTML page and then constructs a network where all nodes are interconnected. All the relevant code can ...

Ways to retrieve the CSS class names associated with an element

To determine if an element has been selected, I rely on checking for the presence of an additional CSS class called "selected" that is added to the element The structure of my element is as follows: <div class="b-wide-option" data-bind="css: { selecte ...

Navigation structure on a website built with HTML

As I dive into HTML5 programming, I am working on creating a simple navigation menu with links to different HTML pages such as "1.html", "2.html," and others. However, when I click on a link like "1.html," it takes me to a new page where the navigation men ...

I have created a Joomla Template that incorporates my own CSS through JavaScript. Is there a method to include a distinct version tag to my custom CSS file, such as custom.css?20180101?

My usual method involves adding a unique tag to the css path in the html section, but my template is incorporating custom CSS through Javascript: if (is_file(T3_TEMPLATE_PATH . '/css/custom.css')) { $this->addStyleSheet(T3_TEMPLATE_URL . &apo ...

Utilizing Django templates to implement custom filters within CSS styling

@register.filter(name='cf') def formattedAmount(amount): # Convert the numerical amount to a string with comma formatting formatted_amount = f"{int(amount):,}" # Determine if the number is positive or negative and set CSS class accor ...

Unable to maintain the height of a div at 100% as it keeps reverting back to 0px

I'm having trouble setting the height of the individual parent columns (and their children) to 100% because for some reason, the div height keeps resetting to 0. The first column contains two child boxes that should each take up 50% of the page heigh ...

Desktop users can enjoy the off-canvas menu feature, while mobile users will have access to the accordion menu option with Foundation 6

My goal is to customize my off-canvas menu in Foundation 6.3.1 so that it appears on desktop while displaying an accordion menu on mobile devices. On desktop, I want the off-canvas menu always visible (see example). For mobile, when the hamburger icon is ...

"Utilize CSS Flexbox to create a layout with set width and uniform

Within a container, I have organized three sections. As I adjust the size of my browser to a maximum width of 668px, I want section 1 and section 3 to be displayed in one row while section 2 is placed below them. The width of section 2 should be proportion ...

UI-Bootstrap selectively adds modal backdrop to specific elements

I have encountered a unique situation with my application where I am displaying a UI-Bootstrap modal inside a div, positioned above a navigation bar. Typically, when the modal is launched, a backdrop (dimmer) covers the entire background. Interestingly, my ...

What could be causing my function to fail <object>?

Within index.php, I am calling the function twice, which includes chart.html. index.php chart_line($valuesNight); //first call chart_line($valuesEvening); //second call ?> <?php function chart_line($jsonDataSource){ ?> < ...