Updating the Navbar-link color with Sass CSS

I've been struggling to change the color of my Bootstrap 4 navbar, but for some reason, it's not working. I've tried various approaches, but none seem to be effective.

Below is the snippet of code for my navbar along with its CSS styling:

<nav class="navbar navbar-light bg-faded">
  <div class="nav navbar-nav">
      <a class="nav-item nav-link active" href="#">HearthBreak <span     class="sr-only">(current)</span></a>
      <a class="nav-item nav-link" href="#">Features</a>
      <a class="nav-item nav-link" href="#">Pricing</a>
      <a class="nav-item nav-link" href="#">About</a>
  </div>
</nav>

.navbar{
    background-color: #252830;
    .nav-item, .nav-link{
        color: #FFF;
    }
}

Although I can modify the NavItem, I am unsure which specific child element needs to be targeted for the desired changes.

Answer №1

To improve the styling, consider using a more specific selector such as .navbar.navbar-light.bg-faded (remember to use !important sparingly):

.navbar.navbar-light.bg-faded{
        background-color: #252830;
        .nav.navbar-nav>a.nav-item.nav-link {
            color: #fff;
        }
    }

Check out the code snippet below:

.navbar.navbar-light.bg-faded {
  background-color: #252830;
}
.nav.navbar-nav>a.nav-item.nav-link {
  color: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-light bg-faded">
  <div class="nav navbar-nav">
    <a class="nav-item nav-link active" href="#">HearthBreak <span     class="sr-only">(current)</span></a>
    <a class="nav-item nav-link" href="#">Features</a>
    <a class="nav-item nav-link" href="#">Pricing</a>
    <a class="nav-item nav-link" href="#">About</a>
  </div>
</nav>

Answer №2

To change the default color of the <a> tag in bootstrap from blue, you can use the ! important property. Here's an example snippet:

.navbar{
    background-color: #252830;
    
}
.nav-item, .nav-link{
        color: #FFF ! important;
    }
<nav class="navbar navbar-light bg-faded>
  <div class="nav navbar-nav">
      <a class="nav-item nav-link active" href="#">HearthBreak <span     class="sr-only">(current)</span></a>
      <a class="nav-item nav-link" href="#">Features</a>
      <a class="nav-item nav-link" href="#">Pricing</a>
      <a class="nav-item nav-link" href="#">About</a>
  </div>
</nav>

Answer №3

Changing the background color of a navbar can be done by overriding the "background-image" property like this:

nav.navbar{
    background-color: blue;
    background-image:none;
    .nav-item, .nav-link{
        color: #000;
    }
}

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

Navigating size measurements in percentages and pixels to achieve flawless alignment

Utilizing the calc property in a solution, I am facing challenges when trying to calculate the percentage width of an element with margins, padding, and borders set in pixels. Take a look at this demo: #form { margin: 200px auto; width: 360px; ...

How to Adjust the Padding of Tree Row in GWT?

Have you ever seen a GWT tree before? It sort of resembles the following structure: <div class="gwt-Tree"> <div style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; margin-left: 0px; padding-left: ...

The margin-bottom CSS class is integrated within Twitter Bootstrap

Is there a standard margin bottom class that can be used? I attempted to use bottom5 like this: <div class="col-lg-2 bottom5"></div> However, it did not have the desired effect. ...

Functionality problem with adjusting font size in jQuery date picker

Recently, I integrated jQuery and datapicker features into my ASP .NET MVC 3 (Razor) project and noticed that the font size of the datapicker is exorbitantly large. Does anyone have any suggestions on how to adjust this issue? Your help would be greatly ...

Display a switch icon based on input created by the user

I've been struggling to implement a toggle button for user-generated input, specifically using a Font Awesome toggle button. Here is the link to my codepen: http://codepen.io/lucky500/pen/bdpzbd along with the code snippet: <div id="list" class= ...

Issue with data type not refreshing in mySQL Workbench

I'm facing an issue with changing the datatype of my "first_name" column. I want it to be VARCHAR(45), but it's stuck at INT(11) as shown in the table diagram and connection provided below. https://i.sstatic.net/0CbkD.png https://i.sstatic.net/8 ...

Tips for making a reusable function that utilizes alternating if statements

After hours of experimenting, I finally achieved a smooth scrolling effect with a bounce at the top and bottom. Now, my challenge lies in creating reusable and clean code for this implementation. Perhaps implementing an algorithm could solve this issue? T ...

What is the best way to focus on an object using a particular variable in javascript?

I am currently developing an online game where each user is assigned a unique ID. Below is the client code used to create a new player: const createNewPlayer = (id) => { return player[player.length] = { x:0, y:0, id:id } } The ...

Tips for transforming JSON data from a specified URL, which requires authorization, into an HTML table or list using PHP

I am attempting to retrieve JSON data from this source: They have provided a 'how to' guide here: I have successfully connected with Authorization and received the raw JSON, but I am unable to format it into a table. This is the code I have wr ...

Understanding the concept of nested children JSON within Angular HTML structures

I am dealing with a JSON structure that contains nested children elements. RowElements can have any number of ColElements, and ColElements can have any number of RowElements within them. Here is an example JSON: "container": { "id" ...

Adapting the column width to display or hide content with CSS styling

I have a row with 2 columns. The left column contains my main content and the right column is a chatroom. I would like users to be able to minimize and open the chatroom, which I already know how to do. However, when the chatroom is open, I want the left ...

Attempting to select the located element, only to be informed that it is not clickable in its current position

I am currently working on developing a bot to extract the percentage of a player in tennis from sofascore.com element = WebDriverWait(driver2, 40).until(EC.presence_of_element_located((By.XPATH, "//div/div[@class='cell__content event-team '] ...

Uh oh! AngularJS just threw an error: Uncaught TypeError - angular.service is not a function. It happened in taskService.js

I've run into some issues with AngularJS, even though I have imported all the necessary libraries. Specifically, I am encountering the following errors: Uncaught TypeError: angular.service is not a function at taskService.js:2 taskFactory. ...

Developing a interactive quiz platform with JavaScript

I recently attempted to develop a straightforward quiz page using Javascript. Everything seemed to be working fine, until I noticed that when I clicked the submit button in the browser, the text generated in the paragraph section (via Script) vanished almo ...

Calculate the total width of LI elements and apply it to the parent UL or DIV

Is there a way to calculate the Total LI width and then set the width for the parent div? Here is an example of my code: <ul> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds&l ...

Using jQuery to compare input with the current select optgroup choices

I'm struggling with looping through options within a form select. The options are grouped into optgroups, and I believe this is where my issue lies as I can't seem to find the correct syntax. My objective is to compare the value entered using .v ...

Leveraging Bootstrap in Bitrix24 CRM for Enhanced User Experience

I'm currently exploring Bitrix24 (On-premise) and am experimenting with implementing Bootstrap on some of the pages. This project already exists, and I am gradually updating each page to provide more organization and structure. I am wondering if it&a ...

Leveraging the (click) event within an HTML template to manage a [hidden] element located in a different template using Angular 2

Within my project, I have two TypeScript files, each containing HTML templates inside the @Component. In one of the templates, there are info cards that can be collapsed or expanded using [hidden]="collapsed". The following function is present in both file ...

Obtaining JSON data in a separate JavaScript file using PHP

I have an HTML file with the following content: // target.html <html xmlns="http://www.w3.org/1999/xhtml"> ... <script src="../../Common/js/jquery-ui-1.10.3.js"></script> <script src="../../Common/js/select.js" type="text/javascript"& ...

Retrieving only the time value from an Angular controller variable when using an HTML input with type="time"

I have a HTML input field: <input type="time" id="exampleInput" name="input" ng-model="ctrl.time" placeholder="HH:mm:ss" min="00:00:00" max="24:00:00" required /> When I enter a time into the input, it is stored in 'ctrl.time&a ...