I used the navbar component on my website but I want to align it from the right to left so the first thing coming in the right is Toursitation (Brand Name).
Can you please help me?
this is the code of the navbar:
<Navbar bg="dark" expand="lg" style={{"padding": "0 10px", "background-color": "#132c33 !important"}}>
<Navbar.Brand href="/">TouriStation</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="mr-auto">
<Nav.Link href="/events" className="navbarSections">Events</Nav.Link>
<Nav.Link href="/resturants" className="navbarSections">Resturants & caffes</Nav.Link>
<Nav.Link href="touristic" className="navbarSections">Touristic</Nav.Link>
<Nav.Link href="accommodations" className="navbarSections">Accomdation</Nav.Link>
<Nav.Link href="malls" className="navbarSections">Malls</Nav.Link>
<Nav.Link href="extraservices" className="navbarSections">Extra services</Nav.Link>
</Nav>
<Form inline>
<FormControl type="text" placeholder="Search" className="mr-sm-2" value={this.state.search} onChange={this.onChangeSearch}/>
<Button variant="outline-info" onClick={() => window.location = "/Search/"+(this.state.search)}>Search</Button>
</Form>
<SplitButton style={{"display": this.state.user ? "none" : "block", "color": "white", marginLeft: "0.5%"}} class="text-white"
menuAlign={{ lg: 'right' }}
title="Join Us"
id="dropdown-menu-align-responsive-2"
variant="info"
>
<Dropdown.Item href="/login">Login</Dropdown.Item>
<Dropdown.Divider />
<Dropdown.Item href="/register">Register</Dropdown.Item>
</SplitButton>
<SplitButton style={{"display": this.state.user ? "block" : "none" , marginLeft: "0.5%"}} class="text-white"
menuAlign={{ lg: 'right' }}
title="Profile"
variant="info"
id="dropdown-menu-align-responsive-2" >
<Dropdown.Item href="/newplace" style={{"display": this.state.user && this.state.Nonuser ? "block" : "none"}}>New Place</Dropdown.Item>
<Dropdown.Item href="/newevent" style={{"display": this.state.user && this.state.Nonuser ? "block" : "none"}} >New Event</Dropdown.Item>
<Dropdown.Divider style={{"display": this.state.user && this.state.Nonuser ? "block" : "none"}} />
<Dropdown.Item href="/profile">My Account</Dropdown.Item>
<Dropdown.Divider />
<Dropdown.Item href="http://localhost:3000/logout/">Sign Out</Dropdown.Item>
</SplitButton>
</Navbar.Collapse>
</Navbar>
Update
that if I use me-auto or '.flex-row-reverse', it will be like this
the orignal one is this
in your code below, remove class name: mr-auto.
<Nav className="mr-auto">
<Nav.Link href="/events" className="navbarSections">Events</Nav.Link>
<Nav.Link href="/resturants" className="navbarSections">Resturants & caffes</Nav.Link>
<Nav.Link href="touristic" className="navbarSections">Touristic</Nav.Link>
<Nav.Link href="accommodations" className="navbarSections">Accomdation</Nav.Link>
<Nav.Link href="malls" className="navbarSections">Malls</Nav.Link>
<Nav.Link href="extraservices" className="navbarSections">Extra services</Nav.Link>
</Nav>
Related
So I'm using react-bootstrap to create my Navbar and I want the Navbar link to redirect to the same page but to the spesific part, I tried using href and assigning id into each div, but it wont' work. How to fix this ? Thanks before
Here's my code:
Navbar part
<Navbar className="MainHeader" expand="lg">
<Navbar.Brand as={Link} to={"/"}>
<img src="#" className='encotekiLogo' alt="main_logo"/>
</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse className="justify-content-end">
<Nav>
<Nav.Link as={Link} href='about' to={'/#about'}>About</Nav.Link>
<Nav.Link as={Link} to={"/Gallery"}>Gallery</Nav.Link>
</Nav>
</Navbar.Collapse>
</Navbar>
This is the code for my part of the page:
<div className= 'aboutUs' id='about'>
<Row className='mb-4' lg={12}>
<h1 style={{
color: '#246234',
}}>
About<br/>
Us
</h1>
</Row>
</div>
I am working on page layout using react-bootstrap. Along with that, I am using pure CSS for it. I have an alignment issue for Navbar on desktop view and mobile view. The components in the top bar should align with the components in the bottom bar in medium & large devices. The layout is different on the mobile device. In large devices Nav toggle bar expands and shrinks in the mobile devices when the user clicks on the toggle bar in the mobile screen, it expands down as shown in the figure. I hope the problem is clear. I have added the code and sample of the layout. Can someone help me to solve this issue?
CODE
<Container noGutters>
<Row className='main-nav d-flex' style={{ alignItems: 'center', justifyContent: 'flex-start' }}>
<Col sm={12} md={4} style={{ textAlign: 'center' }}>
<a href='/'>
visit mysite.com
</a>
</Col>
<Col sm={12} md={4} style={{ textAlign: 'center' }}>
<a href='#about-us'>
<picture>
<source srcSet={require('../public/assets/_logo.png?webp')} type='image/webp' />
<img className='cure-top-logo' src={'/assets/logo.png'} />
</picture>
</a>
</Col>
<Col sm={12} md={4}>
<Dropdown className='top-dropdown-container'>
<Dropdown.Toggle variant='success' id='dropdown'>
Choose an Item
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href='/'>ITEM 1</Dropdown.Item>
<Dropdown.Item href='/'>ITEM 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Col>
</Row>
</Container>
<Navbar style={{ maxHeight: '90px' }} className='sole-bottom-nav' expand={'lg'}>
<Container>
<div className='bottom-nav-logo-container'>
<a href='/cure-adventures/sole2soul'>
<div className='bottom-logo'>
<img alt='' src='assets/header.png' />
</div>
</a>
</div>
<Navbar.Toggle aria-controls='navlinks' />
<Navbar.Collapse id='navlinks'>
<Nav>
<Nav.Link className={activePage === 'about-us' ? ' active' : ''} href='/about-us'>
About Us
</Nav.Link>
<Nav.Link className={activePage === 'treks' ? ' active' : ''} href='/news'>
News
</Nav.Link>
<Nav.Link className={activePage === 'news' ? ' active' : ''} href='/contact'>
Contact us
</Nav.Link>
</Nav>
<div>
<a rel='noopener nofollow' target='_blank' href='https://twitter.com'>
<img src='/assets/twitter.png' width='25px' />
</a>
<a rel='noopener nofollow' target='_blank' href='https://facebook.com'>
<img src='/assets/facebook.png' width='25px' />
</a>
<a rel='noopener nofollow' target='_blank' href='https://instagram.com'>
<img src='/assets/instagram.png' width='25px' />
</a>
<a rel='noopener nofollow' target='_blank' href='/'>
<img src='/assets/linkdin.png' width='25px' />
</a>
</div>
<div>
<Button size={'lg'}>
button
</Button>
</div>
</Navbar.Collapse>
</Container>
</Navbar>
</div>
I want to change hamburger icon and change hamburger icon to x icon when its clicked.
<Navbar collapseOnSelect expand="lg" >
<Navbar.Brand className="mx-5" href="#home">
<StaticImage src="../images/logo.png"
quality={95}
formats={["AUTO", "WEBP", "AVIF"]}
/>
</Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
<Navbar.Collapse id="responsive-navbar-nav" className="justify-content-around">
<Nav className="mr-auto text-center nav-items">
<Nav.Link className="pt-3 pt-md-1" href="#features">About</Nav.Link>
<Nav.Link className="pt-3 pt-md-1" href="#pricing">Skillset</Nav.Link>
<Nav.Link className="pt-3 pt-md-1" href="#features">Our Brands</Nav.Link>
<Nav.Link className="pt-3 pt-md-1" href="#pricing">Partners</Nav.Link>
<Nav.Link className="pt-3 pt-md-1" href="#features">Careers</Nav.Link>
<Nav.Link className="pt-3 pt-md-1" href="#pricing">Contact</Nav.Link>
</Nav>
</Navbar.Collapse>
you can use state for that
const [change, set change] = use state(false)
now in useEffect check your Window's width, if its width is less than a certain number of pixels, u need to change the state value to true.
Now use ternary operator to change icon
{ change ? icon_1 : icon_2 },
Hope u got it!
So I am creating a personal site using react-bootstrap. And here is what the site looks like right now.
The navbar is
<Navbar collapseOnSelect expand="lg" bg="dark" variant="dark">
<Navbar.Brand href="#home">React-Bootstrap</Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
<Navbar.Collapse id="responsive-navbar-nav">
<Nav>
<Nav.Link href="#features">Features</Nav.Link>
<Nav.Link href="#pricing">Pricing</Nav.Link>
</Nav>
<Nav className="ml-auto">
<Nav.Link href="#deets">More deets</Nav.Link>
<Nav.Link eventKey={2} href="#memes">
Dank memes
</Nav.Link>
</Nav>
</Navbar.Collapse>
</Navbar>
and the introduction looks like
<Row>
<Col md={{ span: 4, offset: 2 }}>
<p id='hey'>Hey, I am Max! </p> </Col> </Row>
I really want to shift the navbar to the right with "offset: 2" so that the brand ("React-Bootstrap" in the navbar) can line up with the "Hey, I am Max". I've tried adding padding or margin to Navbar.Brand but it doesn't really work. Is there a way for me to directly add offset:2 to the Navbar.Brand element? Or what might be the best way to accomplish this?
I've been at this for ages and can't seem to work out how to do it. At the moments the NavItem's in my NavBar are aligned to the left. I want them centered. I have tried reading the documentation here https://react-bootstrap.github.io/components/navs/ but it doesn't work.
Here is my Navbar:
<div className="container">
<Navbar collapseOnSelect>
<Navbar.Collapse>
<Nav variant="tabs" defaultActiveKey="/home">
<NavItem>
<NavLink to="/newSite/details">Details</NavLink>
</NavItem>
<NavItem>
<NavLink to="/newSite/tours">Tours</NavLink>
</NavItem>
<NavItem>
<NavLink to="/newSite/pois">POIs</NavLink>
</NavItem>
</Nav>
</Navbar.Collapse>
</Navbar>
</div>
Make sure to add className="justify-content-center" in your Nav opening tag. If you're trying to center your Nav Items within a Navbar and Navbar.Collapse, add an inline style with flex: 1.
<Navbar collapseOnSelect expand="lg">
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
<Navbar.Collapse id="responsive-navbar-nav">
<Nav className="justify-content-center" style={{ flex: 1}}>
<Nav.Item>
<Nav.Link href="/home">Home</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link href="/home">Collection</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link href="/home">Contact</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link href="/home">Blog</Nav.Link>
</Nav.Item>
</Nav>
</Navbar.Collapse>
</Navbar>
Check out the "Alignment and orientation" section in the React Bootstrap Documentation. - https://react-bootstrap.github.io/components/navs/