Bootstrap NAVBAR item t on the left of dropdown list - css

this is my code:
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm">
App
App
<nav >
{% if user.is_authenticated %}
<a class="nav-link" href="#">Link 1</a>
<ul class="navbar-nav">
<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">
{{ user.username }}</a>
<div class="dropdown-menu dropdown-menu-right text-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{% url 'listingfournisseur' %}">Update fournisseur list</a>
<a class="dropdown-item" href="{% url 'updatepayables' %}">Eletronic Payment</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url 'listingclient' %}">Update Clients list</a>
<a class="dropdown-item" href="{% url 'account_logout' %}">Log Out</a>
</div>
</li>
</ul>
{% else %}
<a class="p-2 text-dark" href="{% url 'account_login' %}">Log In</a>
<a class="btn btn-outline-primary" href="{% url 'account_signup' %}">Sign Up</a>
{% endif %}
</nav>
</div>
I m tring to have link1 item just on the left of dropdown.
I don t understand why it is up to dropdown ?
this is what I see:
thanks for help

In you nav add the CSS property display: flex and you will have it one next to the other. But after you will just have to play with the size because an tag don't have "padding" but tag have top, left and bottom "padding".
<nav class="b">
<div>ets</div>
<div><ul>test</ul></div>
</nav>
<style>
.b{
display:flex;
}
</style>

Related

Putting more items in Bootstrap Navbar

I have a bootstrap navbar. I want to put signOut and welcome in the menu bar along with other menu items. Below is the screenshot of my navbar:
I want to put SignOut where the purple arrow is and right beneath "SignOut", I want to put "Welcome userName". I also want to move the logo and company/city name to extreeme left of the nav bar . How can I achieve that? Below is my code:
<nav class="navbar navbar-expand-lg py-5 navbar-dark shadow-sm " style="background-color: #264653;width:100%;" >
<div class="container">
<span class="navbar-brand" style="display:flex;">
<img src="~/Images/InfoOrange.png" alt="ACR" width="70" height="70" class="d-inline-block align-middle mr-2" runat="server" />
<span style="font-size:25px;color:white;"><span style="color:#e9c46a">test City</span><br />test company</span>
</span>
<button type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler"><span class="navbar-toggler-icon"></span></button>
<div id="navbarSupportedContent" class="collapse navbar-collapse">
<ul class="navbar-nav ml-auto">
<%-- <li class="nav-item active">Home <span class="sr-only">(current)</span></li>--%>
<li class="nav-item dropdown nav-item active">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Users
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Details</a>
<a class="dropdown-item" href="Depatment.aspx">Department</a>
<%-- <a class="dropdown-item" href="#">Sections</a>--%>
</div>
</li>
<li> </li>
<li class="nav-item dropdown nav-item active">
<a class="nav-link dropdown-toggle" href="#" id="admindropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Admin
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="NewBoxFolder.aspx">Box/Folder</a>
<a class="dropdown-item" href="#">Configuration</a>
</div>
</li>
<li> </li>
<li class="nav-item dropdown nav-item active">
<a class="nav-link dropdown-toggle" href="#" id="recordsDropDown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Records
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="FileUpload.aspx">BlockChain Upload</a>
<a class="dropdown-item" href="#">Verify</a>
<a class="dropdown-item" href="DocReport.aspx">Report</a>
<a class="dropdown-item" href="BucketList.aspx">S3 List</a>
</div>
</li>
</div>
<div>
<ul>
<li class="nav-item" style="margin-right:5px" >
<a class="nav-link px-5" href="<%= ResolveUrl("~/Pages/SignOut.aspx") %>">Sign Out</a>
</li>
</ul>
</div>
</div>
</nav>
You can contain this section with a class. In this instance I called it <div class="sign">. Then since your ul is a direct child of the parent you can use .sign > ul in your CSS to target that div. To get it in that position you can simply apply absolute positioning which allows you to define the area of the page. In your application, the top right. You can then add in your Welcome & Username area underneath as other unordered list items.
.sign > ul {
position: absolute;
top: 0;
right: 0;
list-style-type: none;
}
<div class="sign">
<ul>
<li class="nav-item" style="margin-right:5px" >
<a class="nav-link px-5" href="<%= ResolveUrl("~/Pages/SignOut.aspx") %>">Sign Out</a>
</li>
</ul>
</div>

Bootstrap 4 dropdown opens in navbar and increases the navbar height

I am developing a laravel app. I need two navbars, number Two below number One, one containing logo and logout link, another containing all the links.
I have achieved the look but the dropdown of the logout link is opening in navbar One resulting in increase in the height of the navbar each time the dropdown is toggled.
Images -
Here is my code -
<div id="header-main">
<nav class="navbar navbar-light bg-light" id="header">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
<img src="{{ asset('images/accounts.png') }}" height="50px">
</a>
#auth
<div class="navbar-nav">
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">{{ __('Logout') }}</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
#csrf
</form>
</div>
</li>
</div>
#endauth
</div>
</nav>
</div>
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<div class="container">
<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">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav mr-auto">
<!-- Authentication Links -->
#guest
<li class="nav-item #if(Route::current()->getName() == 'login') active #endif">
<a class="nav-link" href="{{ route('login') }}"><i class="fas fa-sign-in-alt"></i> {{ __('Login') }}</a>
</li>
#if (Route::has('register'))
<li class="nav-item #if(Route::current()->getName() == 'register') active #endif">
<a class="nav-link" href="{{ route('register') }}"><i class="fas fa-user-plus"></i> {{ __('Register') }}</a>
</li>
#endif
#else
<li class="nav-item #if(Route::current()->getName() == 'home') active #endif">
<a class="nav-link" href="{{ route('home') }}"><i class="fas fa-home"></i> {{ __('Home') }}</a>
</li>
#endguest
</ul>
</div>
</div>
</nav>
Somebody help me.
Use position-absolute on the dropdown menu...
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
username<span class="caret"></span>
</a>
<div class="dropdown-menu position-absolute dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}" >Logout</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;"> #csrf </form>
</div>
</li>
https://codeply.com/p/fHoKygnLv7

Prevent dropdown list in collapsed bootstrap4 navbar from expanding the navbar

I needed a selector that doesn't collapse alongside the rest of the menu in a bootstrap v4 navbar. Got something working, too. See below.
It's a bit hacky as there are actually two language selectors, but one is hidden when the browser window is smaller than the lg-breakpoint in bootstrap. Opposite way round if it is larger than the lg-breakpoint obviously. It works fine - but there might be a more elegant way to do this.
What I don't like is that, when the nav collapses, clicking on the language selector expands the navbar by the height of the dropdown list. Obviously it has to as the language selector is wrapped in the collabsed "nav" - but I'd much rather it'd behave as it does with the lg and wider selector - there the dropdown extends beyond the navbar without changing the size of the navbar.
Is there any way around this?
See these images:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<!--navigation-->
<nav class="navbar sticky-top navbar-dark navbar-expand-lg">
<a class="navbar-brand" href="#">Page Title</a>
<!--language selector for collapsed menu [hidden when viewport larger than medium]-->
<div class="d-lg-none ml-auto">
<ul class="navbar-nav">
<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">🌐 Language</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Language 1</a>
<a class="dropdown-item" href="#">Language 2</a>
<a class="dropdown-item" href="#">Language 3</a>
</div>
</li>
</ul>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar">
<div class="navbar-nav">
<!-- page user is looking at = "nav-link active"-->
<a class="nav-item nav-link active" href="#">Home<span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Link 1</a>
<a class="nav-item nav-link" href="#">Link 2</a>
<div class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">The Team</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Link</a>
<a class="dropdown-item" href="#">Another Link</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">An entirely different link</a>
</div>
</div>
<a class="nav-item nav-link" href="sponsor_us.php">Link 3</a>
<a class="nav-item nav-link disabled" href="#">inactive Link</a>
</div>
</div>
<!--language selector for expanded menu [hidden viewport size medium and down]-->
<div class="d-none d-sm-none d-md-none d-lg-block d-xl-block ml-auto">
<ul class="navbar-nav">
<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">🌐 Language</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Language 1</a>
<a class="dropdown-item" href="#">Language 2</a>
<a class="dropdown-item" href="#">Language 3</a>
</div>
</li>
</ul>
</div>
</nav>
Edit: Here's a jsfiddle link - albeit for some reason that one doesn't use the bootstrap.css file I'd added in the resources. So the menu is white, not black :). You have to change the width of the window that displays the html to see the menu expanding and collapsing.
I know this is old, but this was the ONLY place I'd found this question asked.
Simple way:
css: .popout { position: absolute !important;}
now add popout class to you div that you no longer want to remain inside the navbar while the navbar is collapsed!
<style>
.popout { position: absolute !important;}
</style>
<html>
...
<div class="dropdown-menu dropdown-menu-right popout" ...>
<a class="dropdown-item" href="#">Language 1</a>
<a class="dropdown-item" href="#">Language 2</a>
<a class="dropdown-item" href="#">Language 3</a>
</div>
</html>

How to remove the space between navbar toggle menu collapse and header

I'm using Bootstrap v4.0 for my site, and I have made a basic navbar which goes like this
(Codepen link).
And the problem with this menu is that, when you minimize the page to see how this nav works in md and sm devices, it shows a space between the navbar and the header:
see this image
So my question is, how to remove this space?
Here is the html code:
<nav class="navbar navbar-expand-lg navbar-custom BKoodakBold">
<img id="img1" class="hidden-xs" src="img/letter-logo.png" width="100" height="100"></img><script>rotateAnimation("img1",30);</script><img id="img2" src="img/text-logo.png" width="300" height="100"></img>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbarMd">
<i class="fa fa-bars fa-lg py-1 text-white"></i>
</button>
<div class="navbar-collapse collapse" id="collapsingNavbarMd">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
فروشگاه
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">ویژه</a>
<a class="dropdown-item" href="#">پایین ترین قیمت ها</a>
<a class="dropdown-item" href="#">مرور کردن</a>
<a class="dropdown-item" href="#">ساخت سلاح</a>
<a class="dropdown-item" href="#">پوشاک</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">تجارت</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
راهنما
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">پرسش و پاسخ</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
جامعه
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">وبلاگ</a>
<a class="dropdown-item" href="#">کاتالوگ</a>
<a class="dropdown-item" href="#">درباره</a>
<a class="dropdown-item" href="#">لیست قیمت</a>
<!-- <a class="dropdown-item" href="#">API Documentation</a>
<a class="dropdown-item" href="#">npm package</a> -->
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">مالی</a>
</li>
<button class="btn BJadidBold">ورود/ عضویت</button>
</ul>
</div>
</nav>
I have searched the forum to find a related problem, but I couldn't find anything useful. So it would be best if you can help me with that..
Thanks in advance :)
This space is the overflow of .navbar-custom.
You have to change the height:100px; to auto in media query.
#media only screen and (max-width: 992px) {
.navbar-custom {
height:auto;
}
}
Note:Place media query to bottom of your normal css. In codepen its on
top.

navbar mobile icon not appearing

I using bootstrap(4) but the navbar for small viewports doesn't show the hamburger icon. I think the issue could be the asset isn't loading properly, but I can see it being fetched in chrome dev tools-> network.
(website is based on this template
https://wrapbootstrap.com/theme/velocity-for-products-bootstrap-4-WB0N38R04)
Navbar html
<header id="header" class="header navbar-fixed-top">
<div class="container">
<h1 class="logo">
<span class="text">Cheaper</span>
</h1><!--//logo-->
<nav class="main-nav navbar navbar-right navbar-inverse navbar-expand-md" role="navigation">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-collapse">
<span class="navbar-toggler-icon"></span>
</button><!--//nav-toggle-->
<div id="navbar-collapse" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active nav-item"><a class="nav-link" href="{% url 'home' %}">Home</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'how' %}">How it works</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'faq' %}">FAQ</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'about' %}">About us</a></li>
{% if request.user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'users:detail' request.user.username %}">My Profile</a>
</li>
<li class="nav-item nav-item-cta last">
<a class="btn btn-cta btn-cta-secondary" href="{% url 'account_logout' %}">Log out</a>
</li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{% url 'account_login' %}">Log In</a></li>
<li class="nav-item nav-item-cta last"><a class="btn btn-cta btn-cta-secondary"
href="{% url 'users:postcode' %}">Sign Up</a></li>
{% endif %}
</ul><!--//nav-->
</div><!--//navbar-collapse-->
</nav><!--//main-nav-->
</div><!--//container-->
</header><!--//header-->
css class for the icon
.navbar-toggler-icon {
background: transparent url('../images/hamburger-icon.svg') no-repeat center center;
}
You could use some thing like this. I have changed button to a link. And did changes in the .navbar-toggler-icon class as well.
.navbar-toggler-icon {
background: url('https://image.flaticon.com/icons/svg/198/198416.svg')no-repeat center center;
display: inline-block;
height: 17px;
width: 50px;
}
<header id="header" class="header navbar-fixed-top">
<div class="container">
<h1 class="logo">
<span class="text">Cheaper</span>
</h1>
<!--//logo-->
<nav class="" role="navigation">
<a href="" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-collapse">
<span class="navbar-toggler-icon"></span>
</a>
<!--//nav-toggle-->
<div id="navbar-collapse" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active nav-item"><a class="nav-link" href="{% url 'home' %}">Home</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'how' %}">How it works</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'faq' %}">FAQ</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'about' %}">About us</a></li>
{% if request.user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'users:detail' request.user.username %}">My Profile</a>
</li>
<li class="nav-item nav-item-cta last">
<a class="btn btn-cta btn-cta-secondary" href="{% url 'account_logout' %}">Log out</a>
</li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{% url 'account_login' %}">Log In</a></li>
<li class="nav-item nav-item-cta last"><a class="btn btn-cta btn-cta-secondary" href="{% url 'users:postcode' %}">Sign Up</a></li>
{% endif %}
</ul>
<!--//nav-->
</div>
<!--//navbar-collapse-->
</nav>
<!--//main-nav-->
</div>
<!--//container-->
</header>
<!--//header-->

Resources