Disabling border color for the hamburger icon in the navbar-toggler in Bootstrap with custom CSS

I've been struggling with this issue for a while now. I have searched and attempted various methods to remove the border color from the BS4 hamburger icon when it is clicked (it appears as Yellow on my local machine but in this snippet, it's blue).

Is there anyone who can assist me in resolving this? Any help would be greatly appreciated!

Below is the code snippet that I am working with:

<nav class="navbar sticky-top navbar-expand-lg" style="background-color: #eeeeee">
  <button class="navbar-toggler ml-auto hidden-sm-up float-xs-right" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
    <span><i class="fa fa-navicon"></i></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarToggler">
    <ul class="navbar-nav ml-auto mt-2 mt-lg-0">
      <li class="nav-item active">
        <a class="nav-link active" routerLink="/about" routerLinkActive="active">
          <span>About</span>
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link" routerLink="/projects" routerLinkActive="active">
          <span>Projects</span>
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link" routerLink="/contact" routerLinkActive="active">
          <span>Contact</span>
        </a>
      </li>
    </ul>
  </div>
</nav>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">

Answer №1

This solution worked perfectly in my Bootstrap 4 project.

.navbar-toggler:focus,
.navbar-toggler:active,
.navbar-toggler-icon:focus {
    outline: none;
    box-shadow: none;
}

It is important to note: the outline serves a crucial purpose for accessibility, especially for individuals who rely on keyboards or have visual impairments. For more information, please visit and consider implementing alternative styling for the toggler when it's active or focused.

Answer №2

.menu-toggler,
.menu-toggler:focus,
.menu-toggler:active,
.menu-toggler-icon:focus {
    clear-outline: no;
    delete-border: null;
    conceal-shadow: off;
}

Answer №3

If you want to customize the border color of the burger icon in the Bootstrap navbar when it is clicked, you can do so by modifying the bootstrap.min.css file and locating the button:focus class. From there, you can either change the color or remove the outline entirely. Here's how:

button:focus {

outline: 1px dotted;
outline: 5px auto -webkit-focusring-color;

}

Answer №4

For Bootstrap, the navigation focus does not use border, but rather outline

To remove it, you can use:

button.navbar-toggler.ml-auto.hidden-sm-up.float-xs-right:focus {
    outline: none!important;
}

I hope this information is helpful :>

button.navbar-toggler.ml-auto.hidden-sm-up.float-xs-right:focus {
    outline: none!important;
}
<nav class="navbar sticky-top navbar-expand-lg" style="background-color: #eeeeee">
  <button class="navbar-toggler ml-auto hidden-sm-up float-xs-right" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
    <span><i class="fa fa-navicon"></i></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarToggler">
    <ul class="navbar-nav ml-auto mt-2 mt-lg-0">
      <li class="nav-item active">
        <a class="nav-link active" routerLink="/about" routerLinkActive="active">
          <span>About</span>
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link" routerLink="/projects" routerLinkActive="active">
          <span>Projects</span>
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link" routerLink="/contact" routerLinkActive="active">
          <span>Contact</span>
        </a>
      </li>
    </ul>
  </div>
</nav>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">

Answer №5

This solution is effective for Bootstrap version 5.2:

.navbar-toggler {
  border: none;
  outline: none;

   &:focus,
   &:active,
   &-icon:focus {
     outline: none;
     box-shadow: none;
   }
}

Answer №6

When using Bootstrap v5.1.3:

.navbar-toggler:focus,
.navbar-toggler-icon:focus {
    Remove outline and box-shadow properties for better UI.
}

Answer №7

Solving the Dilemma in BS5:

Instead of piling on additional CSS classes to override Bootstrap styles, the recommended approach is to customize Bootstrap itself. For the current version, Bootstrap 5.2.3, there are two ways to achieve this:

(1) If you're using a SASS-generated Bootstrap, adjust these setting variables as follows:

$navbar-toggler-padding-y:          0;
$navbar-toggler-padding-x:          0;
$navbar-toggler-font-size:          1.5rem;
$navbar-toggler-border-radius:      0;
$navbar-toggler-focus-width:        0;
$navbar-toggler-transition:         none;

$navbar-light-toggler-border-color: none;
$navbar-dark-toggler-border-color:  none;

For more details on customizing Bootstrap via SASS variables, refer to this page.

Please note that customizing Bootstrap through SASS was also possible in BS4, but with potentially different variables.

(2) If you're working with static Bootstrap files and not SASS, you can still customize Bootstrap by tweaking the BS Setting CSS Variables:

Create a separate Bootstrap-CSS-Settings-File and include it AFTER the static Bootstrap-CSS-File in your HTML document. Define the variables you wish to modify here. Here's an example for changing variables for a specific element class:

.navbar {
  --bs-navbar-toggler-padding-y: 0;
  --bs-navbar-toggler-padding-x: 0;
  --bs-navbar-toggler-font-size: 1.5rem;
  --bs-navbar-toggler-border-color: none;
  --bs-navbar-toggler-border-radius: 0;
  --bs-navbar-toggler-focus-width: 0;
  --bs-navbar-toggler-transition: none;
  --bs-navbar-toggler-border-color: rgba(0, 0, 0, 0.1);
}
.navbar-dark {
  --bs-navbar-toggler-border-color: none;
}

It's worth noting that customizing Bootstrap through CSS Variables at a higher level was introduced in BS5. These variables may vary across different sub-versions, and the ones provided apply to version 5.2.3.


The initial query pertained to BS4, but information regarding BS5 customization has been included. This supplementary answer addresses the topic since search engines may display it even when inquiries relate to BS5 specifically.

Answer №8

.nav-toggle {
    border: none;
}

Success with this tweak

Answer №9

Give this a shot! It was successful for me.

.navbar-dark .navbar-toggler {
color: rgba(255, 255, 255, 0) !important;
border-color: rgba(255, 255, 255, 0) !important;
}

Answer №10

button:focus {
    no outline;
    no outline -webkit-focus-ring-color;
}

Answer №11

Below is my solution using SCSS (Sass) :

.navbar-toggler {
    &:focus,
    &:active {
      outline: none;
      box-shadow: none;
    }
  }

  .navbar-toggler-icon {
    background-image: none;
    
    &:focus {
      outline: none;
      box-shadow: none;
    }
  }

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 adjust the size of an SWF object using a Blueprint CSS span range?

Utilizing Blueprint CSS, I am crafting a 3 column layout: LEFT COLUMN: span-6 CENTER COLUMN: span-12 RIGHT COLUMN: span-6 Within the center column, I aim to insert an SWF object that requires a predetermined size upon setup: swfobject.embedSWF(url, "fla ...

Tips for optimizing a CSS file that includes the @page at-rule

When the CSS file for media='print' contains the @page directive, .myreceipt { @page { visibility: hidden; margin: 0 15px; } @page { height: auto; } } The ASP.NET MVC4 built-in minification tool does not ...

Can inline styling be overridden with CSS?

<td class="subrubr" nowrap="nowrap" valign="bottom"> <a name=""></a> Some lengthy text to be shown here. </td> This snippet of code is automatically created by a PHP script. However, ...

Numerous textareas fail to function properly according to JQuery's standards

Need help with resizing multiple textarea elements dynamically as the user types in them (on the Y-axis). Currently, I have code that successfully resizes a single textarea, but it does not work when there are multiple textareas on the page. Here is the c ...

Enhance your visual content by incorporating text onto images with CSS/Bootstrap5

I'm having trouble getting my rows and columns to display on top of my background image. I've been struggling with this issue for a while now. Any assistance on this matter would be greatly appreciated! I'm fairly new to this, so if it&apos ...

What is the process for setting a background image in a React application?

I need help figuring out how to add a background image to my React app. I've searched for solutions on StackOverflow, but I'm still unsure. The image I want to use is named background.jpeg and it's located in the same folder as my App.js fil ...

List of options displayed in a dropdown/selectbox with a menu tree

Would it be possible to incorporate a treemenu within a dropdown/selectbox? My categories are structured like this: <ul id="example"> <li>Category1 <ul> <li><a href="http://www.autisticcuckoo.net">Category1 subcat ...

JavaScript button is not functioning properly to increase or decrease the value in the input field

I'm facing an issue with the javascript increase/decrease buttons on my website. When I assign my JS variable as the class name of the input field, pressing the button results in all input fields being affected simultaneously: https://i.stack.imgur.c ...

Troubleshooting Angular JS loading problems

I'm attempting to implement the Angular-Spinner in my project: Specifically, I want to use it with http.get calls. This is what I have so far: Within controllers: $scope.loading = true; $http.get('js/data/test.json').success(function(resu ...

Organizing Files with Identical Names in Separate Folders Using Gulp.js

I'm currently working on a forum and need to convert my CSS files to SASS. Here is the project hierarchy: app/ components/ 404/ controllers/ ...

Executing a function in Angular 2 depending on the class assigned to a <div>

In my HTML code, I am using *ngFor to iterate through an array of messages. <div *ngFor="let message of messages; let i=index" [focused]="i === activeIndex;" [ngClass]="{'message-list-active': activeIndex === i }" (click)="onAddtoMessag ...

Display an image from a Google image search when hovering over a specified data attribute

My goal is to add a code snippet that will assign a class of "hoverme" to a table cell. When a user hovers over that cell, an ajax query will be triggered using the data attribute containing information stored there to perform a Google search. Below is a ...

Display the JSON data in a table when the button is clicked

My goal is to display JSON data retrieved from a web service in a table format only after a button click. Although I have successfully fetched the data, I want it to be visible in a table only upon clicking the button. The current code displays table row n ...

Increasing counter on the backend using PHP or JavaScript

Having done my research, I am struggling to find a suitable solution for my project. I need a server-side incremental counter that resets daily. The goal is for every website visitor to see the same number on the counter. Is there a PHP script or JavaScr ...

Creating a circular image in a responsive navigation bar

Currently, I have a chat navigation bar with divs representing different users, each displaying a photo of the user. My goal is to have these photos displayed as perfect circles. To achieve this, I am using padding-bottom and width properties. However, I a ...

What is the best semantic HTML element to use for organizing comments: <ol>, <ul>, <article>, or <blockquote>?

I conducted some thorough research but couldn't find a satisfactory answer. I'm pondering whether it would be more beneficial to continue using li elements or transition to the article element for displaying comments. For Example 1: <ol clas ...

Improving ASP.NET MVC 4 output by bundling whitespace and formatting

While not a critical issue, I find it quite bothersome that when using the bundling feature in ASP.NET MVC 4, there is minimal white space in the output. For example: If manually rendered: <head> <title>Example page</title> < ...

Is there a way for me to manage the appearance of the printed document's layout?

I have successfully added 3 print buttons to my website, each one designed to print a specific portion (div) of the webpage. Here is the code snippet for this functionality: function printPage(id) { var html="<html>"; //html+="<link rel="st ...

CSS: Ancestor menu disappears when sub menu is hovered over

The webpage in question has an interesting interactive feature: Upon hovering over the "About Us" menu item, the background transitions to black with white text. Subsequently, when moving onto the sub-menu item "Meet our team", the original content under ...

Fluid pictures in Mozilla Firefox not fluid

My images are shrinking in Chrome, as expected, but they don't adjust their size in Firefox and IE9. I'm using the CSS below: .pics img { max-width: 100%; height: auto; width: auto\9; /* ie8 */ border: 1px solid #CCC; }​ ...