Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add icon to react-bootstrap navBar?

I'm using react-bootstrap and trying to add an icon to the 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 not positioned properly in the navbar

enter image description here

And from the official site, i can't find any example of adding icon to the navbar.

Thanks

like image 235
Kenneth Avatar asked Nov 29 '16 04:11

Kenneth


People also ask

What is collapseOnSelect?

collapseOnSelect: It is used to collapse the Navbar on click onSelect function is triggered of a descendant of a child <nav> element. expand: It is used to denote the breakpoint below which our Navbar will collapse.


2 Answers

I think you will need to add a bit of CSS there.

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

Check working example on JSFiddle

Depending on your image size you can adjust it for your code

like image 157
wolendranh Avatar answered Sep 19 '22 07:09

wolendranh


It's a dirty hack, but I had the same problem and added a className, 'nav-logo-' to my image and then did the following CSS:

.nav-logo {
  float: left !important;
  margin-top: -15px !important;
}
like image 42
dianafaye17 Avatar answered Sep 17 '22 07:09

dianafaye17