I basically have a pretty simple question, but my portfolio will look better if I can make this simple addition.
I want my NavBar in bootstrap to be in 3 columns, essentially like the image I've mocked up below.
I currently have the base bootstrap navBar setup with the default code like so:
<!-- Navigation -->
<nav class="navbar navbar-expand-lg bg-white fixed-top">
<div class="container">
<a class="nav-link" href="#">my name goes here</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="#">about</a></li>
<li class="nav-item"><a class="nav-link" href="#">resume</a></li>
</ul>
</div>
</div>
</nav>
I can make a weird version look right with messing with padding and stuff, but I dont want that. The hardest part for me is understanding the responsive version, and having the one link on the left (work) and two links on the right (about, resume) merge into one dropdown navigation and have the 'my name goes here' become the header above it on mobile.
Any help, or a point in the right direction would be great.
Also, it can be assumed my CSS is the base bootstrap CSS.
Thanks
UPDATE
<!-- Navigation -->
<nav class="navbar navbar-light navbar-expand-md bg-success justify-content-between">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".dual-nav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse dual-nav w-50 order-1 order-md-0">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link pl-0" href="#">work <span class="sr-only">work</span></a>
</li>
</ul>
</div>
Colin Grant
<div class="navbar-collapse collapse dual-nav w-50 order-2">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="">about</a></li>
<li class="nav-item"><a class="nav-link" href="">resume</a></li>
</ul>
</div>
</div>
This seems to work perfectly, any tips for makign it better?
Thanks
Following is how I did it using bootstrap 4. When screen size is <992px right side of the navbar will collapse into a button.
<nav class="navbar navbar-expand-lg navbar-dark bg_color_primary sticky-top d-flex justify-content-between ">
<div class="navbar-nav col-4 align-items-start ">
<div class="text-white bg_color_primary_light rounded-circle p-2">
Work
</div>
</div>
<div class="col-4 d-flex justify-content-center">
<a class="navbar-brand text-white brand_name " href="">
BrandName
</a>
</div>
<button class=" navbar-toggler ml-auto align-items-end" type="button" data-toggle="collapse"
data-target="#navbarNavDropdown"
aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse col-4 " id="navbarNavDropdown">
<div class="navbar-nav ml-auto ">
<a class="nav-item nav-link" href="">About</a>
<a class="nav-item nav-link" href="">Resume</a>
</div>
</div>
</nav>
Related
There was a problem with extra padding in the navbar after the site icon. Initially, the idea was to place links that are located to the left of the icon closer to the left edge using me-3, but then the icon of the site is shifted to the right, which I basically don’t need.Therefore, I have a question. Is it possible to make the same indents from the site icon and links without shifting this icon from the center or how to remove the indent between the icon and links on the right side of the navbar.
<nav class="navbar navbar-expand-lg navbar-dark fixed-top" id="scroll">
<div class="container-fluid">
<div class="collapse navbar-collapse order-1 order-lg-0 dual-collapse2" id="navbarNavAltMarkup">
<ul class="navbar-nav ms-auto">
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#articles">기사들</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#mission">우리의 임무</a>
</li>
</ul>
</div>
<a class="navbar-brand order-0" href="#">
<img src="img/marslogo.png" alt="" width="30" height="30">
</a>
<div>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="collapse navbar-collapse order-3 dual-collapse2" id="navbarNavAltMarkup"
>
<ul class="navbar-nav">
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#">사진들</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#">문의하기</a>
</li>
</ul>
</div>
</div>
</nav>
I am using bootstrap 4 to make a simple theme.
My problem is, that when I view the page on mobile, and click the menu button, the menu shows up for 1 second, and then hide it self. If I click the button gain, it wont show up.
Demo site here
My menu source code from the browser (I don't use the sticky classes)
<header class="header header-sticky- header-transparent__">
<div class="container">
<div class="row">
<div class="col-12">
<nav class="navbar navbar-expand-lg">
<!-- Logo START -->
<a class="navbar-brand" title="IQ Logistics Kft." href="https://kozetgyapot-arak.hu">
<img class="img-fluid" src="https://themes.potenzaglobalsolutions.com/html/bulky/images/logo.svg" alt="IQ Logistics Kft.">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav m-auto_">
<li class="nav-item"><a class="nav-link" title="Kezdőlap" href="https://kozetgyapot-arak.hu/">Kezdőlap</a></li><li class="nav-item"><a class="nav-link" title="Rólunk" href="https://kozetgyapot-arak.hu/rolunk">Rólunk</a></li><li class="nav-item"><a class="nav-link" title="Szolgáltatások" href="https://kozetgyapot-arak.hu/szolgaltatasok">Szolgáltatások</a></li><li class="nav-item"><a class="nav-link" title="Elérhetőségeink" href="https://kozetgyapot-arak.hu/elerhetosegeink">Elérhetőségeink</a></li> </ul>
</div>
<div class="mr-5 mr-lg-0 d-sm-flex d-none align-items-center">
<a class="btn btn-primary" href="https://kozetgyapot-arak.hu/arajanlat-kerese">Árajánlat kérése <i class="fa fa-chevron-right ml-1"></i></a>
</div>
</nav>
</div>
</div>
</div>
</header>
Thank you, if someone can help me.
It seems to work fine with this html. Note that I did leave out the Font Awesome stylesheet in the snippet below. Also note that the popper script is bundled in the bootstrap script so you heave to remove it from your project as an extra script.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js"></script>
<header class="header header-sticky- header-transparent__">
<div class="container">
<div class="row">
<div class="col-12">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" title="IQ Logistics Kft." href="https://kozetgyapot-arak.hu">
<img class="img-fluid" src="https://themes.potenzaglobalsolutions.com/html/bulky/images/logo.svg" alt="IQ Logistics Kft.">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav m-auto">
<li class="nav-item"><a class="nav-link" title="Kezdőlap" href="https://kozetgyapot-arak.hu/">Kezdőlap</a></li>
<li class="nav-item"><a class="nav-link" title="Rólunk" href="https://kozetgyapot-arak.hu/rolunk">Rólunk</a></li>
<li class="nav-item"><a class="nav-link" title="Szolgáltatások" href="https://kozetgyapot-arak.hu/szolgaltatasok">Szolgáltatások</a></li>
<li class="nav-item"><a class="nav-link" title="Elérhetőségeink" href="https://kozetgyapot-arak.hu/elerhetosegeink">Elérhetőségeink</a></li>
</ul>
</div>
<div class="mr-5 mr-lg-0 d-sm-flex d-none align-items-center">
<a class="btn btn-primary" href="https://kozetgyapot-arak.hu/arajanlat-kerese">Árajánlat kérése <i class="fa fa-chevron-right ml-1"></i></a>
</div>
</nav>
</div>
</div>
</div>
</header>
I've got a nav bar with a subtitle, the subtitle uses the technique from here:
Adding a subtitle to a Bootstrap Navbar
Unfortunately, when I added the sub-title, I lost the right-alignment on my nav bar - meaning I need some items to be right aligned, and they were, but not anymore since adding the sub-title.
Any idea how I could combine nav-bar sub-title with right-align?
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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="d-flex flex-column">
<div class="d-sm-flex d-block flex-nowrap">
<div class="collapse navbar-collapse">
<ul id="navbar-section-list" class="navbar-nav mr-auto">
... a bunch of li/a here to represent left aligned items
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown-item-right">
<a id="refresh-button" class="nav-link" href="#">Refresh</a>
</li>
<li class="nav-item dropdown dropdown-item-right justify-content-end">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Account</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<span id="account-info-header" class="dropdown-item-text"></span>
<a class="dropdown-item">Settings</a>
<a class="dropdown-item" href="/auth/v1/logout">Log out</a>
</div>
</li>
</ul>
</div>
</div>
<small id="navbar-node-info"></small>
</div>
</nav>
I think that right-alignment of "Refresh" and "Account" were provided by the "mr-auto" attribute on:
<ul id="navbar-section-list" class="navbar-nav mr-auto">
But sadly I have no idea why it stopped working with "flex"...
I tried adding a justify-content-end on the second ul.navbar-nav but it made no difference, still no right alignment.
here is the jsfiddle for your problem https://codepen.io/irinnahar/pen/JQamQy?editors=1000 you just need to add w-100 to your <div class="d-flex flex-column w-100"> class
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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="d-flex flex-column w-100">
<div class="d-md-flex d-block flex-nowrap">
<div class="collapse navbar-collapse">
<ul id="navbar-section-list" class="navbar-nav mr-auto">
... a bunch of li/a here to represent left aligned items
</ul>
<ul class="navbar-nav ">
<li class="nav-item dropdown-item-right">
<a id="refresh-button" class="nav-link" href="#">Refresh</a>
</li>
<li class="nav-item dropdown dropdown-item-right justify-content-end">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Account</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<span id="account-info-header" class="dropdown-item-text"></span>
<a class="dropdown-item">Settings</a>
<a class="dropdown-item" href="/auth/v1/logout">Log out</a>
</div>
</li>
</ul>
</div>
</div>
<small id="navbar-node-info"></small>
</div>
</nav>
aight hello there, so im using bootstrap 4 and trying to create a navbar menu
here is my code
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="#">Home</a></li>
<li class="nav-item"><a class="nav-link" href="#">Features</a></li>
<li class="nav-item"><a class="nav-link" href="#">Pricing</a></li>
</ul>
</div>
<ul class="navbar-nav"><li class="nav-item">Login</li></ul>
</nav>
So what im trying here is I want a navbar menu and some items but I want some items not be collapsed and at the same time to be in the right.
I tried moving the item I want to be in the right moved to after toggler button and it's working exactly as I want, but in small devices and in desktop device it shows back to the left.
I tried moving the item I want to be in the right after the div collapse element but it collapses in small devices.
The problem was solved by separating the navbars into two separate divs, using bootstrap4 row and col, and giving a padding of 0 to the two separate divs. I used an in-line style to position the Login item but this is just for illustration purposes. It would be better to convert the in-line style into a class.
<div class="container-fluid">
<div class="row">
<div class="col-8 p-0">
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="height:4rem;">
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarText" aria-controls="navbarText"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="#">Home</a></li>
<li class="nav-item"><a class="nav-link" href="#">Features</a></li>
<li class="nav-item"><a class="nav-link" href="#">Pricing</a></li>
</ul>
</div>
</nav>
</div>
<div class="col-4 p-0 ">
<nav class="navbar-nav navbar-light bg-light" style="height:4rem;">
<ul class=" list-unstyled mr-4" style="margin-top:1rem;"> <li class=" float-right">Login</li>
</ul>
</nav>
</div>
</div>
</div>
How can i put navbar-brand on the left and hamburger icon to the right? i tried floating in my css but it not working.. maybe because of the line that i marked on the code. In the photo is explained what i want to achieve. Explained
<nav class="navbar sticky-top navbar-expand-sm navbar-light">
<div class="row mx-auto">
<a class="navbar-brand" href="home.html">
<img src="Images/logo.png" width="65" height="50">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="home.html">Почетна<span
class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Информации</a>
<a class="nav-item nav-link" href="#">Контакт</a>
</div>
</div>
</div>
</nav>
You can use this bootstrap 4 navbar snippet
https://startbootstrap.com/snippets/navbar-logo/
or use float-left and float-right bootstrap classes
Use justify-content-between; Here's more info.
<nav class="... d-flex justify-content-between">
<!-- Your brand & content || [*****] link link link -->
<div class="...">
<div class="brand-logo">...</div>
<div class="hyperlinks">...</div>
</div>
<!-- Your menu -->
<div class="menu">...</div>
</nav>
add flex-direction: row-reverse; to .navbar. no need to float them.