Modifying the Navbar link color in Bootstrap 4 specifically for the sign-up button: A Step-by-Step

I've been struggling to change the link color of the signup class in one of my navigation items to white. No matter what I do, the color remains default and does not change. Here is the code snippet:

HTML

<nav class="navbar navbar-expand-md  bg-faded ">
  <a class="navbar-brand" href="#">
    <img src="../assets/images/close.png" class="img-fluid" style="width:50px; height:50px" alt="">
  </a>

    <button class="navbar-toggler" type="button"
          >
    <span class="navbar-toggler-icon"></span>
  </button>


 <div class="collapse navbar-collapse"
      >
    <ul class="navbar-nav ml-auto">

      <li class="nav-item">
        <a class="nav-link" routerLink="/home" >Item 1</a>
      </li>

      <li class="nav-item signin">
        <a class="nav-link" routerLink="/sign-in" >Sign in</a>
      </li>

       <li class="nav-item signup">
        <a class="nav-link" routerLink="/sign-up" >Sign Up</a>
      </li>
    </ul>
  </div>
</nav>

CSS

.navbar {
  position: relative;
  background-color:#ffffff;
     box-shadow: 0 2px 2px -2px rgba(0,0,0,.2);
}

.nav-item{
    margin:5px;
}

.signin, .signup {
    border:2px solid;

}

.signin {
    border-color:#232323 !important;
}

nav .nav-item ul li a.signin {
    color:#232323;
}

.signin:hover {
    background-color:#232323;
    color:#ffffff;
}

nav .nav-item ul li .signin a :hover {
    color:#ffffff;
}

.signup {
    background-color:#44A423;
    border-color:#44A423;
}
.navbar-light .navbar-nav .nav-item .nav-link {

    font-size:23px;
    padding:10px 20px;
}

.navbar-light .navbar-nav .nav-item.signup .nav-link {
    color:#fff;
    font-size:23px;
}

How can I successfully change the link color of the signup nav item to white? Any help or suggestions would be greatly appreciated! For reference, please check out the complete example provided in the comments section.

Answer №1

To change the text color to white in the li tag, simply add the class "text-white" as shown below:

  <li class="nav-item signup text-white">
    <a class="nav-link" routerLink="/sign-up" >Sign Up</a>
  </li>

Answer №2

Insert it in this manner

.signup a {
  color: white;
}

Make sure to apply the color on the anchor tag, not the list item

section {
  background... (content truncated for brevity)
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css">
<div class="container">
  <nav class="navbar navbar-expand-md  bg-faded ">
    <a class="navbar-brand" href="#">
      <img src="../assets/images/close.png" class="img-fluid" style="width:50px; height:50px" alt="">
    </a>

    <button class="navbar-toggler" type="button">
<span class="navbar-toggler-icon"></span>
  </button>


    <div class="collapse navbar-collapse">
      <ul class="navbar-nav ml-auto">

        <li class="nav-item">
          <a class="nav-link" routerLink="/home">Item 1</a>
        </li>

        <li class="nav-item signin">
          <a class="nav-link" routerLink="/sign-in">Sign in</a>
        </li>

        <li class="nav-item signup">
          <a class="nav-link text-white" routerLink="/sign-up">Sign Up</a>
        </li>


      </ul>
    </div>
  </nav>
</div>
<section> ... (content truncated for brevity)

Answer №3

The absence of the .navbar-light class in the HTML means that you are unable to access the corresponding CSS styles.

.navbar-nav .nav-item .nav-link {
    font-size:23px;
    padding:10px 20px;
}

.navbar-nav .signup .nav-link {
    color:#fff;
    font-size:23px;
}

Hover-Example:

.navbar-nav .nav-item .signup .nav-link:hover{
    color:#fff;
    font-size:23px;
}

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

Chrome users may encounter difficulty grabbing the horizontal textarea scrollbar if a border-radius has been applied

Check out this JSFiddle for more information <textarea wrap="off" rows="5" style="border-radius: 4px">aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbbaaaaaaaaaaabbbbbbbbb aa ...

What are the steps to get the Dropdown Button to function in HTML and CSS?

Currently, I am in the process of constructing a website and have set it up so that when the window width is less than 768px, the navbar collapses into a vertical orientation. The issue I am facing is that even though the navbar collapses, the individual i ...

Styling the Padding of MUI Select Component in ReactJS

Currently, I am facing an issue with the Material UI Select component where I am trying to decrease the padding within the element. The padding seems to be a property of one of the subclasses .MuiOutlinedInput-input, but my attempts to change the padding h ...

Prevent Previous/Next Buttons, Autofill, and Completion Bar on iPhone Web Forms

Can the bar on web forms that includes the (Previous|Next) Autofill and Done button be disabled or suppressed? I know there are solutions for native apps, but I am specifically working on a web app. I'm wondering if there is a simple attribute to add ...

Guide to taking a screenshot of an HTML page using Javascript, Jquery, and HTML5 functionality

I am looking to add a unique feature to my website - the ability to capture the current image of my webpage with just the click of a button. Inspired by Google's "send feedback" function, I want to implement something similar on my own site. After res ...

Unable to refresh CSS file

Struggling with updating my website stylesheet. Everything seems to be in place - files uploaded correctly, cache cleared, even manually refreshed the CSS file multiple times. The only solution that works is renaming the CSS file and updating the link. A ...

In Android, make sure to include a newline after a heading when using the <h3> tag

Lately, I've been experimenting with HTML tags on my Android device. I noticed that when I use the <h3> tag, it adds a line space automatically before the next line. In HTML, you can remove this space by setting the padding and margin to 0px. Ca ...

Finding elements based on their class can be accomplished by using XPath

Can you show me how to effectively utilize the :not selector to choose elements in a scenario like this: <div class="parent"> <div class="a b c"/> <div class="a"/> </div> I am trying to select the div with only the class & ...

I am currently in the process of transitioning a Gatsby project from CSS to SCSS, and running into obstacles with the

Currently, I am in the process of converting a Gatsby starter project that utilizes Lost grid from CSS to SCSS for better organization and efficiency. The original starter project can be found here: https://github.com/wpioneer/gatsby-starter-lumen The ma ...

Creating a Seamless Bond Between JavaScript and HTML

I've been struggling to find a helpful and straightforward solution to a simple problem. On my web page, I have five image placeholders that should be filled with one of nine random pictures. To achieve this, I wrote a JavaScript code that generates r ...

Unable to implement the bootstrap panel class as expected

It seems like the bootstrap panel class is not being applied in this code snippet: <div class="container main-content"> <div class="row"> <div class="col-sm-3"> <div class="panel panel-primary"> ...

Dismiss the pop-up box by clicking outside its borders

I have created a unique homepage featuring pop-up boxes with login fields. The background dims when a pop-up appears, and the user should be able to close the pop-up by clicking outside the box boundaries. Although the function closeOverlay works when the ...

Prevent pinch zoom in webkit (or electron)

Is there a way to prevent pinch zoom in an electron app? I've tried different methods, such as using event.preventDefault() on touchmove/mousemove events in JavaScript, adding meta viewport tags in HTML, adjusting -webkit-text-size-adjust in CSS, and ...

Disable the time selection feature in the text input field

Despite seeing the same question asked before for this issue, I am looking for a solution that does not involve replacing the textbox with the same ID. When Timepicker is selected in the dropdown menu timepicker, it should activate in the textbox (which i ...

Organizing content on a webpage with specific pixel measurements

I have a div and am utilizing Bootstrap 5. I'd like to have the Description and Length elements on separate lines when the page width is <=1024px. <div class="col-3 col-md-4 col-lg-3"> <div class="card d- ...

The dropdown in the UIB Typehead is not displaying

I am facing an issue with the UI-Bootstrap typeahead where the dropdown does not display when the data is received. $scope.obtainUsers = function (valor) { console.log(valor) $http({ method: "POST", url ...

What is the best way to retrieve a value from an `<input type="number">` element and incorporate it into the script section?

Check out this code snippet <html> <head> head <title>title</title> </head> <script> var val1 = parseInt(document.getElementById('input1')); function bytton() { window.alert(val1); ...

Display the scrollbar within a flexitem by utilizing flexbox styling

I am currently setting up my HTML website with Bootstrap flex and I have a specific layout in mind. I want the inner div to have scrollbars while the outer div fills up the rest of the page. Take a look at this example: <div class="d-flex align-items- ...

Steps for creating a sleek vertical slider with transitional effects using JavaScript and HTML

Take a look at my code snippet: <table> <tr> <td onclick="shownav()">Equations of Circle <div id="myDownnav" class="sidenav"> <a>General Info</a> <a>In Pola ...

What is the process for obtaining an HTML form, running it through a Python script, and then showcasing it on the screen

I am inquiring about the functionality of html and py script. .... The user enters 3 values for trapezoidal data from the html form: height, length of side 1, and length of side 2, then clicks submit. The entered values are then sent to be calculated using ...