Center Navbar Brand on mobile devices. I can't seem to get my navbar brand centered on mobile device...I am trying to use media queries and flexbox attributes to no avail....Is this achievable with bootstrap classes or custom css??? Thanks! :)
<nav class="navbar navbar-expand-lg navbar-default fixed-top nav-menu navbar-
light bg-white">
<div class="container">
<div class="header-border">
<a class="navbar-brand hidden-sm-down" href="index.html">
<img src="/images/logo.png" alt="masslogo">
</a>
<a class="navbar-brand-two hidden-md-up" href="index.html">
<img src="/images/mpsmall.png" alt="masssmalllogo">
</a>
</div>
<button class="navbar-toggler nav-button" type="button" data-toggle="collapse" data-target="#myNavbar">
<div class="bg-dark line1"></div>
<div class="bg-dark line2"></div>
<div class="bg-dark line3"></div>
</button>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
Our Solution
</li>
<li class="nav-item">
How We Help
</li>
<li class="nav-item">
Blog
</li>
<li class="nav-item">
Contact
</li>
<li class="nav-item"><div class="dropdown"> <a class="nav-link m-2 dropdown-toggle"
href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"> Resources </a> <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Knowledge base</a> <a class="dropdown-item"
href="#">Video tutorials</a> <a class="dropdown-item"
href="#">Forms</a> </div></div></li>
</ul>
<ul class="navbar-nav navbar-btns">
<a class="search" href="/search"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" role="img">
<title>Search</title>
<path d="M914.876 846.934l-226.894-226.92c93.082-124.27 83.508-301.176-29.516-414.14-61.952-61.97-143.146-92.954-224.366-92.954s-162.414 30.984-224.384 92.954c-123.922 123.922-123.922 324.812 0 448.768 61.97 61.934 143.146 92.936 224.366 92.936 66.918 0 133.624-21.368 189.772-63.402l226.952 226.936 64.07-64.178zm-480.794-190.038c-60.536 0-117.486-23.604-160.238-66.414-88.38-88.362-88.38-232.174-.018-320.538 42.828-42.812 99.72-66.398 160.298-66.398 60.536 0 117.486 23.56 160.256 66.398 88.32 88.38 88.32 232.174 0 320.538-42.87 42.81-99.762 66.414-160.298 66.414z">
</path></svg></a><li class="nav-item login"><a class="btn btn-success
btn-cust" href="https://masspay.myisolved.com/UserLogin.aspx?ReturnUrl=%2f"><span class="fa fa-user-circle mr-1"></span>Client Login</a></li></ul>
</div>
</nav>
Use the flex utility classes to align the Navbar components. You'll also need a hidden spacer to push the brand to center on mobile. Also note the display classes have changed from hidden-* to d-*...
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="d-flex flex-grow-1">
<span class="w-100 d-lg-none d-block"><!-- hidden spacer to center brand on mobile --></span>
<a class="navbar-brand d-none d-lg-inline-block" href="index.html">
<img src="//placehold.it/100x30" alt="masslogo">
</a>
<a class="navbar-brand-two mx-auto d-lg-none d-inline-block" href="index.html">
<img src="//placehold.it/40" alt="masssmalllogo">
</a>
<div class="w-100 text-right">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#myNavbar">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="collapse navbar-collapse flex-grow-1" id="myNavbar">
<ul class="navbar-nav ml-auto flex-nowrap">
<li class="nav-item">
Our Solution
</li>
<li class="nav-item">
How We Help
</li>
<li class="nav-item">
Blog
</li>
<li class="nav-item">
Contact
</li>
<li class="nav-item">
<div class="dropdown"> <a class="nav-link m-2 dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Resources </a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Knowledge base</a> <a class="dropdown-item" href="#">Video tutorials</a> <a class="dropdown-item" href="#">Forms</a> </div>
</div>
</li>
</ul>
<ul class="navbar-nav navbar-btns">
<a class="search" href="/search">
...
</a>
<li class="nav-item login">
...
</li>
</ul>
</div>
</nav>
https://www.codeply.com/go/w13DoSZyVc
Similar questions:
Center an element in Bootstrap 4 Navbar
Bootstrap 4 Navbar align logo center and toggle icon on the left
Related
I started to edit my web and I added second logo in navbar. It looks okay on pc but when I try it on mobile, navbar is covering image.. I am using bootstrap 4 so I would like to know how that navbar is up the image and not in image... Thanks.
<nav id="menu" class="navbar fixed-top navbar-toggleable-sm bg-faded px-5 stin">
<button class="navbar-toggler navbar-toggler-right mr-3" 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="row d-flex align-items-end">
<div class="col-1 col-md-2 mr-1 mr-sm-0">
<a class="navbar-brand" href="#"> <img src="img/logo_barva.svg" height="90" class="pb-1"></a>´
</div>
</div>
<div class="collapse navbar-collapse prava pr-3" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto ">
<li class="nav-item active">
<a class="nav-link" href="#">DOMŮ<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="uklid.html">ÚKLIDOVÉ SLUŽBY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pece.html">DOMA PÉČE</a>
</li>
<!--<li class="nav-item dropdown">
SLUŽBY<span class="caret"></span>
<ul class="dropdown-menu col-xs-12" >
<li><a class="dropdown-item" href="uklid.html">Úklidové služby</a></li>
<li><a class="dropdown-item" href="pece.html">Domácí péče</a></li>
</ul>
</li>-->
<li class="nav-item">
<a class="nav-link" href="kariera.html">KARIÉRA</a>
</li>
<li class="nav-item">
<a class="nav-link" href="kontakt.html">KONTAKT</a>
</li>
</ul>
</div>
<div class="logo2">
<div class="col-5 col-md-2 mr-1 mr-sm-0">
<a class="navbar-brand pr-5" href="pece.html"> <img src="img/doma_pece.png" height="65" class="pb-1"></a>´
</div>
</div>
Well, I managed to do it.
If someone needed it:
#media screen and (max-width: 768px) {
body {
padding-top: 15.3rem;
padding-bottom: 0rem;
color: #5a5a5a;
}
}
I'm making my first project as a programmer, and I found myself with a trouble that I'm not making to solve.
I made a navbar that expands. But, when it is expanding, other elements are going down too. I don't know the reason, and after two days trying to solve the problem, I got no success.
Here is an image that illustrates the situation:
Then, here is my code:
<header id="aermenu" class="sticky-top">
<div class="container">
<div class="row">
<div id="saudacoes" class="col-1 order-lg-1 order-2 align-self-center">
<p class="pt-3">Saudações, <br/> <span>Usuário</span></p>
</div>
<div class="col-lg-8 col-2 offset-lg-1 order-lg-2 order-1">
<nav class="navbar navbar-expand-lg navbar-light">
<button class="navbar-toggler mt-3" data-toggle="collapse" data-target="#menubar">
<span class="fas fa-bars text-white"></span>
</button>
<div class="collapse navbar-collapse" id="menubar">
<ul class="navbar-nav">
<li class="nav-item">
<a href="aeraer.html" class="nav-link" onmouseover="aerhvr(this,'on')" onmouseleave="aerhvr(this,'off')">
<img src="imagens/bt-aer.png" class="img-fluid btu" id="btaer"/>
<img src="imagens/bt-aer-on.png" class="img-fluid btu" id="btaeron"/>
</a>
</li>
<li class="nav-item">
<a href="aerlogin.html" class="nav-link" onmouseover="loginhvr(this,'on')" onmouseleave="loginhvr(this,'off')">
<img src="imagens/bt-login.png" class="img-fluid btu" id="btlogin"/>
<img src="imagens/bt-login-on.png" class="img-fluid btu" id="btloginon"/>
</a>
</li>
<li class="nav-item">
<a href="aerplay.html" class="nav-link" onmouseover="playhvr(this,'on')" onmouseleave="playhvr(this,'off')">
<img src="imagens/bt-play.png" class="img-fluid btu" id="btplay"/>
<img src="imagens/bt-play-on.png" class="img-fluid btu" id="btplayon"/>
</a>
</li>
<li class="nav-item">
<a href="aerequipe.html" class="nav-link" onmouseover="equipehvr(this,'on')" onmouseleave="equipehvr(this,'off')">
<img src="imagens/bt-equipe.png" class="img-fluid btd" id="btequipe"/>
<img src="imagens/bt-equipe-on.png" class="img-fluid btd" id="btequipeon"/>
</a>
</li>
<li class="nav-item">
<a href="aerrank.html" class="nav-link" onmouseover="rankhvr(this,'on')" onmouseleave="rankhvr(this,'off')">
<img src="imagens/bt-rank.png" class="img-fluid btd" id="btrank"/>
<img src="imagens/bt-rank-on.png" class="img-fluid btd" id="btrankon"/>
</a>
</li>
<li class="nav-item">
<a href="aercontato.html" class="nav-link" onmouseover="contatohvr(this,'on')" onmouseleave="contatohvr(this,'off')">
<img src="imagens/bt-contato.png" class="img-fluid btd" id="btcontato"/>
<img src="imagens/bt-contato-on.png" class="img-fluid btd"id="btcontatoon"/>
</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="col-2 order-3 align-self-center ml-auto d-none d-sm-block">
<div class="justify-items-end" >
<img src="imagens/joker-sign.png" class="img-fluid jsign"/>
</div>
</div>
</div>
</div>
</header>
If someone could help me to understand where I'm making some mistake, I would be grateful.
(Also, if you need to me to bring here other parts of the code, like CSS or JS, just tell me. I really think the problem is with the HTML part, but I don't know where).
i made it for you, content is not exactly you want but i give you idea of that,
if you need logo in your right side simply add your image after navbar-toggler class so it pull right and for your p tag name called Saudações, <br/> <span>Usuário give it class mr-auto so it pull left and give additional margin you want.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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>
<p class="mr-auto ml-5">Saudações, <br/> <span>Usuário</span></p>
<img class="navbar-brand" style="width: 50px;" src="pdfs/img/lol1.jpg">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
The menu on a laptop or desktop is like I want it to be, however on a small screen, I'm 'losing' to options; the search icon and the translate menu. What I would like to achieve is that the logo, the search icon, and the translate bar, and the hamburger menu, are in line with each other. Alternatively, an input field on the second line below the logo and the hamburger menu is workable too.
So far I have been working with the various Bootstrap nav bar components, but have not managed to get it right. In the code below there is also some smarty used, but I don't think that's of any impact on the solution.
Hope someone can point me in the right direction to take it a step further.
Thanks!
<nav class="navbar navbar-color-on-scroll navbar-expand-lg fixed-top scrolling-navbar navbar-transparent" color-on-scroll="170">
<div class="container-fluid">
<div class="navbar-header">
</div>
<div class="navbar-translate">
{* requires popper.js rel="tooltip" *}
{if $page_alias == 'hanse_311'}
<a class="navbar-brand" href="{root_url}" rel="noreferrer" title="{$sitename} | Design based on Now_UI-Kit." data-placement="bottom" target="_blank"><img id="header-logo" class="logo" alt="{$sitename}" src="{CGSmartImage src="{uploads_url}/images/cms/Logo_Hanse_UisgeBeatha.png" alt="{$sitename}" title="{$sitename}" noresponsive='1' notag=1 noembed=1}" height="90vh"/></a>
{else}
<a class="navbar-brand" href="{root_url}" rel="noreferrer" title="{$sitename} | Design based on Now_UI-Kit." data-placement="bottom" target="_blank"><img id="header-logo" class="logo" alt="{$sitename}" src="{CGSmartImage src="logo_1.jpg" alt="{$sitename}" title="{$sitename}" noresponsive='1' notag=1 noembed=0}" height="90vh"/></a>
{/if}
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-bar top-bar"></span>
<span class="navbar-toggler-bar middle-bar"></span>
<span class="navbar-toggler-bar bottom-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbarNav" data-nav-image="{CGSmartImage src="logo_2.jpg" alt="{$sitename}" title="{$sitename}" noresponsive='1' notag=1 noembed=0}" data-color="orange"}
{Navigator action='default' template="{#theme_resource#}navigator_navigation_multilevel_bootstrap_menu.tpl"}
<form class="form-inline ml-auto text-dark" data-background-color="#990000">
{if $browser_lang != 'nl'}
<div class="form-group my-md-2 col-sm-9">
{include file='cms_template:google_Translate'}
</div>
{/if}
<div class="form-group col-sm-3">
{svg use="search"}
</div>
</form>
</div>
</div>
</nav>
As per request to add some HTML, first the header:
<div class="page-header page-header-small">
<div class="page-header-image" style="background-image: url('data:image/jpeg;base64,.........;">
</div>
<div class="content-center">
<div class="row">
<div class="col-md-8 ml-auto mr-auto">
<div class="rellax" data-rellax-speed="-3" style="transform: translate3d(0px, 0px, 0px);">
<h1 class="title">Downloads</h1>
</div>
<h4>
Downloaden van (technische) bootdocumenten
</h4>
<nav aria-label="breadcrumb" role="navigation">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="text-info">U bent hier: </li>
<li class="breadcrumb-item">
<a href="https://develop.some-site.eu/" title="Home">
Home
</a>
</li>
<li class="breadcrumb-item">
Links
</li>
<li class="breadcrumb-item active" aria-current="page">Downloads</li>
</ol>
</nav>
</nav>
</div>
</div>
</div>
</div>
And the code from menu from while in small screen mode
<nav class="navbar navbar-color-on-scroll navbar-expand-lg fixed-top scrolling-navbar navbar-transparent" color-on-scroll="170"><div class="container-fluid">
<div class="navbar-header"></div>
<div class="navbar-translate">
<a class="navbar-brand" href="https://develop.some-site.eu" rel="noreferrer" title="some site | Design based on Now_UI-Kit." data-placement="bottom" target="_blank"><img id="header-logo" class="largeLogo" alt="some site" src="data:image/png;base64,......">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="https://develop.some-site.eu/">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Boot en Schipper</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/boot-en-schipper/afkomst-naam">Afkomst naam</a>
<a class="dropdown-item" href="https://develop.some-site.eu/boot-en-schipper/dehler-36-jv">Dehler 36 JV</a>
<a class="dropdown-item" href="https://develop.some-site.eu/boot-en-schipper/hanse_311">Hanse 311</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Logboek</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/logboek_categorie/logboek_artikelen">Artikelen</a>
<a class="dropdown-item" href="https://develop.some-site.eu/logboek_categorie/gps-tracks">GPS Tracks</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Media</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/fotos-en-videos-rondom-some-site/fotoalbums">Fotoalbums</a>
<a class="dropdown-item" href="https://develop.some-site.eu/fotos-en-videos-rondom-some-site/youtube">Youtube</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Links</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/links-downloads/downloads">Downloads</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="https://develop.some-site.eu/gastenboek">Gastenboek</a>
</li>
</ul>
<form class="form-inline ml-auto text-dark" data-background-color="#990000">
<div class="form-group my-md-2 col-sm-9">
<div id="google_translate_element"></div>
</div>
<div class="form-group col-sm-3">
<svg preserveAspectRatio="none" class="icon icon-search"><use xlink:href="#icon-search"></use></svg>
</div>
</form>
</div>
</div>
</nav>
Site on the development environment, if you resize, you see what I mean and try to achieve development site
This question already has answers here:
Bootstrap NavBar with left, center or right aligned items
(14 answers)
Center an element in Bootstrap Navbar
(10 answers)
Closed 4 years ago.
I need to achieve the brand logo in left, menu items to be center and couple of buttons in the right. I have tried using the flexbox approach but the center items does not align well. and also the brand logo has a wide space with a clickable link.
JS Fiddle
<nav class="navbar navbar-light navbar-expand-md bg-faded justify-content-center">
<div class="container">
<img src="assets/logo/" alt="logo">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100 ml-auto" id="collapsingNavbar3">
<ul class="navbar-nav w-100 justify-content-center">
<li class="nav-item active">
<a class="nav-link" href="#">How it works</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Become a tutor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item">
<a class="btn btn-link" href="#">Sign In</a>
</li>
<li class="nav-item">
<a class="btn btn-primary" href="#">Sign Up</a>
</li>
</ul>
</div>
</div>
</nav>
Answering my own question few months later.
<nav class="navbar navbar-light navbar-expand-md bg-white justify-content-center main--navigation dark-header">
<a href="#" class="navbar-brand d-flex w-50 mr-auto">
<img src="assets/images/logo-header.svg" class="navigation__logo" alt="Logo" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100" id="collapsingNavbar">
<ul class="navbar-nav w-100 justify-content-center">
<li class="nav-item active">
<a class="nav-link" href="#">Browse</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">How it works</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Become a tutor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Prices</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item dropdown no-arrow mx-1 nav-link px-0">
<button id="bookmarksDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" type="button" class="btn btn-outline-secondary btn-outlined" data-original-title="Bookmarks"><img src="assets/icons/bookmark-header-dark.svg"></button>
<div class="dropdown-list dropdown-menu dropdown-menu-right" aria-labelledby="alertsDropdown">
<h6 class="dropdown-header">
Bookmarks
</h6>
</div>
</li>
<li class="nav-item dropdown no-arrow mx-1 nav-link px-0">
<button id="messagesDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" type="button" class="btn btn-outline-secondary btn-outlined" data-original-title="Notifications"><img src="assets/icons/bell-header-dark.svg"></button>
<div class="dropdown-list dropdown-menu dropdown-menu-right" aria-labelledby="notificationsDropdown">
<h6 class="dropdown-header">
You do not have any notifications yet
</h6>
</div>
</li>
<li class="nav-item dropdown no-arrow mx-1 ml-3 mr-0 nav-link px-0">
<a class="nav-link dropdown-toggle pr-0" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="header__profile__title d-inline-block text-right align-middle">
<span class="mr-2 d-none d-block header__profile__name">Aaron Alexander</span>
<span class="mr-2 d-none d-block header__profile__role">Student</span>
</div>
<div class="header__profile d-inline-block">
<img class="img-profile rounded" src="assets/images/andrew-franklin.jpeg" alt="Aaron Alexander">
</div>
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
<a class="dropdown-item" href="#">
<i class="fas fa-user fa-sm fa-fw mr-2"></i>
Profile
</a>
<a class="dropdown-item" href="#">
<i class="fas fa-cogs fa-sm fa-fw mr-2"></i>
Settings
</a>
<a class="dropdown-item" href="#">
<i class="fas fa-list fa-sm fa-fw mr-2"></i>
Activity Log
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
<i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
Logout
</a>
</div>
</li>
</ul>
</div>
</nav>
That container div you added after the nav makes you loose the flexbox attributes.
You also set the logo with the class "w-100" which takes all possible width.
I removed those and got a nicely aligned navbar.
<nav class="navbar navbar-light navbar-expand-md bg-faded justify-content-center align-items-center">
<img src="assets/logo/" alt="logo">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100 ml-auto" id="collapsingNavbar3">
<ul class="navbar-nav w-100 justify-content-center">
<li class="nav-item active">
<a class="nav-link" href="#">How it works</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Become a tutor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item">
<a class="btn btn-link" href="#">Sign In</a>
</li>
<li class="nav-item">
<a class="btn btn-primary" href="#">Sign Up</a>
</li>
</ul>
</div>
</nav>
Here's a fiddle with the results.
here is my working example.
You just need to put all content into single div in order to Justify content with bootstrap classes. Also, I am using navbar-brand and making them show hide depending on screen resolution. You can do that with js which might be smoother once the page loads completely.
#media only screen and (max-width: 991px) {
.logo {
display: flex;
}
.collapse .navbar-brand {
display: none
}
}
#media only screen and (min-width: 992px) {
.logo {
display: none;
}
.collapse .navbar-brand {
display: none;
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light d-flex ">
<a class="navbar-brand logo" href="#">Navbar</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 justify-content-between" id="navbarSupportedContent">
<a class="navbar-brand" href="#">Navbar</a>
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
This question already has answers here:
Bootstrap NavBar with left, center or right aligned items
(14 answers)
Bootstrap align navbar items to the right
(24 answers)
Closed 4 years ago.
I'm very new to bootstrap so this is probably an easy question for most. I have a navbar, want two nav items and an input field to be on the left side of the navbar. With the two remaining nav items on the right. I have tried messing with the classes to make this happen and using the "float-left" and "float-right" classes but no joy :(
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">L'amour</a>
<button class="navbar-toggler navbar-toggler-right" 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 float-left">
<a class="nav-link float-left" href="order.php">Contact Us</a>
</li>
<li class="nav-item float-left">
<a class="nav-link float-left" href="order.php">Testimonial</a>
</li>
<li class="nav-item">
<input class='form-control' type='text' name='search' placeholder='Search for wedding...'>
</li>
<li class="nav-item float-right">
<a class="nav-link float-right" href="order.php">Order Wesbite</a>
</li>
<li class="nav-item dropdown float-right">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownBlog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Account
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownBlog">
<a class="dropdown-item" href="signIn.php">Login</a>
<a class="dropdown-item" href="sign-up">Sign up</a>
<a class="dropdown-item" href="homeUser.php">Account details</a>
<a class="dropdown-item" href="logout.php">Logout</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
You can use the following solution:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">L'amour</a>
<button class="navbar-toggler navbar-toggler-right" 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">
<!-- left menu -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="order.php">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="order.php">Testimonial</a>
</li>
<li class="nav-item">
<input class='form-control' type='text' name='search' placeholder='Search for wedding...'>
</li>
</ul>
<!-- right menu -->
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="order.php">Order Wesbite</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownBlog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Account
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownBlog">
<a class="dropdown-item" href="signIn.php">Login</a>
<a class="dropdown-item" href="sign-up">Sign up</a>
<a class="dropdown-item" href="homeUser.php">Account details</a>
<a class="dropdown-item" href="logout.php">Logout</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
Separate menu into two ul left and right use class mr-auto for left and my-0 for the right one
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">L'amour</a>
<button class="navbar-toggler navbar-toggler-right" 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 mr-auto">
<li class="nav-item float-left">
<a class="nav-link float-left" href="order.php">Contact Us</a>
</li>
<li class="nav-item float-left">
<a class="nav-link float-left" href="order.php">Testimonial</a>
</li>
<li class="nav-item">
<input class='form-control' type='text' name='search' placeholder='Search for wedding...'>
</li>
</ul>
<ul class="navbar-nav my-lg-0">
<li class="nav-item ">
<a class="nav-link float-right" href="order.php">Order Wesbite</a>
</li>
<li class="nav-item dropdown float-right">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownBlog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Account
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownBlog">
<a class="dropdown-item" href="signIn.php">Login</a>
<a class="dropdown-item" href="sign-up">Sign up</a>
<a class="dropdown-item" href="homeUser.php">Account details</a>
<a class="dropdown-item" href="logout.php">Logout</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
https://jsfiddle.net/raj_mutant/v00oy85h/
To achieve this you should wrap your nav items in different ul
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">L'amour</a>
<button class="navbar-toggler navbar-toggler-right" 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">
<li class="nav-item float-left">
<a class="nav-link float-left" href="order.php">Contact Us</a>
</li>
<li class="nav-item float-left">
<a class="nav-link float-left" href="order.php">Testimonial</a>
</li>
<li class="nav-item">
<input class="form-control" type="text" name="search" placeholder="Search for wedding...">
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item ">
<a class="nav-link" href="order.php">Order Wesbite</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownBlog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Account
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownBlog">
<a class="dropdown-item" href="signIn.php">Login</a>
<a class="dropdown-item" href="sign-up">Sign up</a>
<a class="dropdown-item" href="homeUser.php">Account details</a>
<a class="dropdown-item" href="logout.php">Logout</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
Note: View the snippet in full screen
You are forgetting to use clearfix class to parent class that contain float-left or float-right class