Customize the active text color of breadcrumbs in Bootstrap

My goal is to change the text color "About us" in the breadcrumb to black, but my attempts have been unsuccessful.

<ol class="breadcrumb">
    <li class="disabled"><a href="index.html">Home</a></li>
    <li class="active"><a href="#">About us</a></li>
</ol>

I applied the following CSS but it did not have the desired effect.

.breadcrumb > .active {
   color: black;
   text-decoration: none;
}

Any thoughts on why it is not working?

Answer №1

According to Bootstrap's Documentation, the active item in breadcrumbs should not have a link inside.

It makes sense as the last item usually represents the current active page and should not be clickable, hence the <a> element is unnecessary.

Follow the standard Bootstrap structure for breadcrumbs like this:

<ol class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Library</a></li>
  <li class="active">Data</li>
</ol>

There are two ways to change the color of the active text:

Method #01:

  1. Visit the Customizing Bootstrap page.
  2. Go to the Breadcrumbs section.
  3. Replace the default value of @breadcrumb-active-color variable with your desired value, e.g. #000.
  4. Go to the Download section and click on "Compile and Download" Button.

Method #02:

You can override Bootstrap styles in your custom CSS file.

.breadcrumb >.active {
   color: black;
}

If you still want a link inside the active item, you can modify the selector like this:

.breadcrumb >.active a {
   color: black;
}

@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css");

.breadcrumb > .active,
.breadcrumb > .active a {
  color: black;
}
<ol class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Library</a></li>
  <li class="active">Data(Without Link)</li>
</ol>
<ol class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Library</a></li>
  <li class="active"><a href="#">Data(With Link)</a></li>
</ol>

Answer №2

To style the link within the active list item, apply the following CSS:

.breadcrumb > .active a{
   color: black;
   text-decoration: none;
}
<ol class="breadcrumb>
     <li class="disabled"><a href="index.html">Home</a></li>
     <li class="active"><a href="#">About us</a></li>
</ol>

Answer №3

Check out this helpful tip:

Here's the CSS code snippet:

.breadcrumb > .active a{
color: #333333; <!-- You can choose your preferred color here -->
}

And here is the HTML code snippet:

<ol class="breadcrumb">
<li class="active"><a href="#">Active Link</a></li>
</ol>

If you want to create a CMS template from scratch using Basic Bootstrap Framework, you can find an example here.

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

Loading content dynamically with AJAX and enabling smooth page scrolling

Looking for a solution to this issue. I have a button on my webpage that, when clicked, uses AJAX to load content into a "div" element below the button. Everything functions properly except for one problem - every time the button is pressed, the page scrol ...

Ways to conceal just a portion of the bootstrap sidebar?

I'm looking to create a sidebar using 'vue-bootstrap' that can be hidden when clicked, but I only want to hide 80% of the width of the sidebar. How can I achieve this effect of partially hiding the sidebar? <b-button v-b-toggle.sidebar-1 ...

Determine the number of elements in a Css selector and restart the counter whenever an element

Need help with counting elements that are not part of a regular list structure. Here is a code example to clarify: Fiddle I don't have much control over the HTML. The DOM structure looks like this: <div class="body"> <div><p clas ...

Combining classes in SCSS to create more versatile styles

Here is some code snippet: input { border:1px solid black; color:#FFF; } Another snippet: .input { padding:0px 5px 0px 3px; } How can we use SASS/SCSS to achieve the following: input.input This will apply the .input class directly to ...

When I toggle the div to close on mobile, I want it to show on desktop

My attempt at creating a toggle button to hide and show content was not successful. I struggle with coding in Javascript/Jquery. In the desktop view, the description displays perfectly (see image here), but in mobile view, there is a button to toggle hidi ...

Using PHP, show a specific table row when clicked by matching the ID

I am currently developing an application for a school project that manages tests. This app allows employees to log in, select a client, register clients, and conduct tests with them, all while storing the data in a database. I have successfully implemente ...

Tips for relocating a popup window''s position

A situation has arisen in my application where a popup window is opened with the following code: function newPopup(url, windowName) { window.open(url,windowName,'height=768,width=1366,left=10,top=10,titlebar=no,toolbar=no,menubar=no,location=no,d ...

Attempting to preserve the CSS transform effect as I switch between menu options

Whenever I stop hovering over my element, it reverts back to its original position. However, I want it to remain in place when I am navigating through the "sousmenu" menu and only return to its original position when I am not hovering over the "sousmenu". ...

Load JavaScript files in order within the <body> tag and trigger a callback function when all files have

Currently, my website (which is actually a Cordova/Phonegap app) has the following scripts in the <head>: <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="appPolyfills.js"></script> ...

How can CSS be used to change the text color of input placeholder in Edge Browser?

While using Edge Browser, I encountered an issue where I was unable to change the input placeholder color. The :-ms-input-placeholder selector was not working on Edge, although it functioned properly on IE 10 and IE 11. input:-ms-input-placeholder { ...

Disabling click events on a span tag in Angular 6: A step-by-step guide

Is there a way to disable the click event for deleting hours with the 'X' symbol based on a condition? Thank you in advance. <table navigatable class="<some_class>"> <tbody> <tr *ngFor="let item of ...

Troubleshooting overflow problems when centering a UL menu with an unspecified width

Trying to create a demo where the scrollbars are removed when resizing smaller, but adding overflow: hidden causes issues with sub-menus. Demo Link HTML <nav> <ul> <li><a href="#">Menu Item</a></li> ...

The pseudo element 'not' in CSS is currently not functioning as expected when applied to an anchor tag

When working with CSS, I encountered an issue while trying to apply a pseudo element on hover and active states of anchor tags. Unfortunately, my code was not producing the desired outcome. a:not(a[name="nobgcolor"]):hover{color:#ffff35;background-color:# ...

AngularJS: Updating data in controller but not reflecting in the HTML view

Within my AngularJS app, I've come across the following code: example.html <div> <p>{{name}}</p> </div> <div> <button ng-click="someFunction()"></button> </div> exa ...

Can I create interactive stacked shapes with CSS and/or JavaScript?

Trying to explain this may be a challenge, so please bear with me. I need to create an "upvote" feature for a website. The number of upvotes is adjustable in the system settings. The upvote controls should resemble green chevrons pointing upwards. For exa ...

Personalizing Web Push Alerts (Google Chrome)

I successfully implemented a web push notification for Google Chrome using Google Project and Service Worker. One thing I'm curious about is how to customize or style the push notification. The plain message box doesn't quite cut it for me – I ...

Creating a jQuery variable in version 1.9.1 results in an error, whereas in version 1.8.3 it does not succeed

Recently updated to version 1.9.1 and encountered some technical difficulties. Despite that, everything works fine except for one thing: var $newthumbs = $(' <div id=\"car-7\" class=\"thumbnail_car thumbnail span2&bso ...

Guide to creating an autoplay feature for a CSS slider

I have created a basic HTML/CSS slider with just 2 slides and I'm looking to set it to automatically switch slides every 7 seconds. Since I'm not well-versed in jQuery or JavaScript, I'm hoping for a CSS-based solution... Could you assist m ...

Issues with jQuery animate not functioning properly when triggered on scroll position

I found a solution on Stack Overflow at this link, but I'm having trouble implementing it properly. The idea is to make an element change opacity from 0 to 1 when the page is scrolled to it, but it's not working as expected. The element is locat ...

Using jQuery, encapsulate an image within a div element and transfer the floating style attribute from the image to the div

Can anyone assist me in wrapping an image within a div along with transferring the float setting? This is my current code: $('.photo-img').wrap('<div class="photo-wrap" />'); I would like the new div to inherit the float proper ...