3

I'm trying to change the color of the three lines and the border around the icon

through css but not sure which tags to call to modify it.

CSS:

.navbar-toggler .navbar-toggler-icon {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,255,255, 1)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
}
.navbar-toggler-icon{
  border-color: white;
}
/* change the background color */
.navbar-custom {
    background-color: red;
}
/* change the link color */
.navbar-custom .navbar-nav .nav-link {
    color: yellow;
}
/* change the color of active or hovered links */
.navbar-custom .nav-item.active .nav-link,
.navbar-custom .nav-item:hover .nav-link {
    color: black;
}

HTML:

 <nav class="navbar navbar-expand-md navbar-custom">
      <a class="navbar-brand" href="#"><img src="img/logo.png" class="img-fluid"></a>
      <button class="navbar-toggler" type="button" data-toggle="collapse"    data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
          <li class="nav-item active">
            <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Services</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Pricing</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Contact</a>
          </li>
        </ul>
      </div>
</nav>
WebDevBooster
  • 14,674
  • 9
  • 66
  • 70
esim
  • 49
  • 1
  • 6
  • Re: the 2 answers below, they appear to have [found the dup](https://stackoverflow.com/questions/42586729/bootstrap-4-change-hamburger-toggler-color), and then simply pasted and reformatted the existing code/answer. https://stackoverflow.com/help/referencing – Carol Skelly Feb 16 '18 at 10:23

1 Answers1

-2

This answer was previously posted here: Bootstrap 4 Change Hamburger Toggler Color

From the other author:

"The navbar-toggler-icon (hamburger) in Bootstrap 4 uses an SVG background-image. There are 2 "versions" of the toggler icon image. One for a light navbar, and one for a dark.."

// this is a black icon with 50% opacity
.navbar-light .navbar-toggler-icon {
   background-image: url("data:image/svg+xml;..");
}
// this is a white icon with 50% opacity
.navbar-inverse .navbar-toggler-icon {
    background-image: url("data:image/svg+xml;..");
}

"So if you want to change the color of this image to something else, you can customize the icon. For example, here I set the RGB value to pink (255,102,203). Notice the stroke='rgba(255,102,203, 0.5)' value in the SVG data:"

.custom-toggler .navbar-toggler-icon {
   background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,102,203, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
 }
Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
HTML Guruz
  • 379
  • 2
  • 8
  • 1
    Looks like you just copy/paste my [answer from the duplicate](https://stackoverflow.com/a/42587673/171456), and then changed a few words at the top. – Carol Skelly Feb 16 '18 at 10:16
  • @ZimSystem Acknowledged. – HTML Guruz Feb 16 '18 at 10:37
  • Imbecilic. Used to be you can just override the CSS. Now you have to dip into SVG for an icon with three lines?? Seriously? just a border with radius and three thick lines. Bootstrap has gone off the rails. Should've stopped at 3, IMO. Not as badly as font-awesome, though. – Jolly Jul 23 '20 at 01:46