How to add an icon to the navBar bootstrap reaction?

I am using action-bootstrap and trying to add an icon to NavBar

      <Navbar.Header>
        <Navbar.Brand>
          <a href="#">&#9776; React-Bootstrap
          <img src={logo} style={{width:100, marginTop: -7}} />
          </a>
        </Navbar.Brand>
        <Navbar.Toggle />
      </Navbar.Header>

However, the icon is incorrect in the navigation bar.

enter image description here

And from the official site I can’t find an example of adding an icon to the navigation bar.

thank

+4
source share
2 answers

I think you need to add some CSS.

.navbar-brand {
  display: flex;
  align-items: center;
}
.navbar-brand>img {
  padding: 7px 14px;
}

Check working example on JSFiddle

Depending on the size of the image, you can customize it for your code

+3
source

This is a dirty hack, but I had the same problem and added the class name, "nav-logo-" to my image, and then did the following CSS:

.nav-logo {
  float: left !important;
  margin-top: -15px !important;
}
0
source

Source: https://habr.com/ru/post/1662215/


All Articles