Using react-bootstrap I have a logo on the left and the menu items on the right. When collapsing the burger menu appears on the right side as expected.
I am trying to reposition the items on collapse and have the burger menu on the left and the logo at the center.
This question seems appropriate: Re-positioning items on navbar collapse in Bootstrap However I can't replicate the effect because I am using react-bootstrap and the syntax is very different.
This is my code:
import React, { Component } from 'react';
import { Navbar, Nav, Container } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import logo from '../assets/WT_JustLogo_White.png';
import './CustomNavbar.scss';
class CustomNavbar extends Component {
render() {
return (
<Navbar sticky="top" expand="lg" bg="dark" variant="dark">
<Container>
<Navbar.Brand>
<Link to="/">
<img src={logo}
className="Nav-logo"
alt="logo"
/>
</Link>
</Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
<Navbar.Collapse id="responsive-navbar-nav">
<Nav className="ml-auto">
<Nav.Item>
<Nav.Link className="menuLink" eventKey={1}>
<Link className="text-light menuText" to="/">HOME</Link>
</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link className="menuLink" eventKey={3}>
<Link className="text-light menuText" to="/About">ABOUT</Link>
</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link className="menuLink" eventKey={4}>
<Link className="text-light menuText" to="/Contact">CONTACT</Link>
</Nav.Link>
</Nav.Item>
</Nav>
</Navbar.Collapse>
</Container>
</Navbar>
);
}
}
export default CustomNavbar;
use order like this: add order-1 to brand with mx-auto:
<Navbar.Brand href="#home" className="order-md-0 mx-auto order-1">React-Bootstrap</Navbar.Brand>
add order-0 to nav collapse:
<Navbar.Toggle aria-controls="-navbar-nav" className="order-md-1 order-0"/>