Navbar direction bootstrap 4 - css

Is there a default bootstrap way to make the navigation bar expand upwards instead of downwards?
My navbar has sticky-top but when you start the page the navbar is at the bottom of the page. While scrolling down the navbar eventually sticks to the top.
When the navbar is at the bottom of the page the menu should expand upwards instead of down.
Is there or something else in bootstrap to get the menu expand direcion to go up? If so I can just remove the class thats handeling this with javascript when the page is scrolled further then 100vh of the document.
I know about the .dropup but this only works with default dropdowns and now with navbars.
I know how to fix this with css but I was wondering if bootstrap 4 has a build in option for this.
.canvas{
height: 800px;
padding-top: 140px;
}
<div class="canvas">
<nav class="navbar navbar-dark bg-dark sticky-top">
<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 navbar-inverse" id="navbarSupportedContent">
<ul class="navbar-nav container">
<li data-menuanchor="Link1">Link1</li>
<li data-menuanchor="Link2">Link2</li>
<li data-menuanchor="Link3">Link3</li>
</ul>
</div>
</nav>
</div>
<!-- Ignore underneath -->
<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">
<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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

Do you want like this?
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<div class="pos-f-t bg-dark">
<div class="collapse" id="navbarToggleExternalContent">
<ul class="navbar-nav container">
<li data-menuanchor="Link1">Link1</li>
<li data-menuanchor="Link2">Link2</li>
<li data-menuanchor="Link3">Link3</li>
</ul>
</div>
<nav class="navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
For more info visit this link

Related

How to set full width for div when hover ?- navbar dropdown - Angular - Bootstrap 4

I'm trying to set full width for the div. since its has slideDown/Up effect i could catch exact css to change its width.
So far I've below snippet.
i could able to see class open which is dynamically appending to div when hover it. but i don't how to set full width for that div.
$(".dropdown").hover(
function() {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideDown("400");
$(this).toggleClass('open');
},
function() {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideUp("400");
$(this).toggleClass('open');
}
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-md bg-dark navbar-dark fixed-top">
<button class="navbar-toggler navbar-toggler-right" 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>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<div class="navbar-nav">
<div class="nav-item dropdown dropdown-slide dropdown-hover">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">slide down to see</a>
<div class="dropdown-menu row" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">First Item</a>
<a class="dropdown-item" href="#">Second One</a>
<a class="dropdown-item" href="#">The last but not the least</a>
</div>
</div>
</div>
</div>
</nav>
Is that any possible to have the same effect with pure CSS without using jquery?
I've tried lots of SO css threat but couldn't find exactly what im looking for
thanks
Here is how to make it fullwidth.
I have added a new class fullwidth to dropdown and modified some properties. Hope this will help :)
$(".dropdown").hover(
function() {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideDown("400");
$(this).toggleClass('open');
},
function() {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideUp("400");
$(this).toggleClass('open');
}
);
.fullwidth.dropdown {
position: static;
}
.fullwidth .dropdown-menu {
right: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-md bg-dark navbar-dark fixed-top">
<button class="navbar-toggler navbar-toggler-right" 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>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<div class="navbar-nav">
<div class="nav-item dropdown dropdown-slide dropdown-hover fullwidth">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">slide down to see</a>
<div class="dropdown-menu row" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">First Item</a>
<a class="dropdown-item" href="#">Second One</a>
<a class="dropdown-item" href="#">The last but not the least</a>
</div>
</div>
</div>
</div>
</nav>

Logo in Bootstrap NavBar shifts hamburger to the left when browser is small

I was trying something today. In a Bootstrap NavBar, if the logo (navbar-brand) is text only then the hamburger stays on the right. But if the logo is an image, the hamburger shifts to the left when you resize the browser. I can't figure this out.
I'm currently working on Angela Yu's Udemy course and completed the Bootstrap module. Now trying to use what I learned to re-create my own website.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet" />
<section id="title">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">
<img src="img/techsnazzy-logo.png" width="30%" height="30%" alt="TechSnazzy Logo" />
</a>
<!-- <a class="navbar-brand" 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 id=" navbarSupportedContent>
<ul class="navbar-nav mr-auto">
<li class="nav-item">Home</li>
</ul>
</div>
</nav>
</div>
</section>
enter image description here
Use flex-nowrap bootstrap class to your navbar. Read some information on the documentation here https://getbootstrap.com/docs/4.2/utilities/flex/#wrap
From w3schools
The flex-wrap property specifies whether the flexible items should
wrap or not.
Also avoid to use width and height on logo image because it creates extra space between logo and nav-item like this:
Use width: 30% on .navbar-brand instead and set width: 100% to logo image.
I updated your code, please check:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet" />
<section id="title">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light flex-nowrap">
<a class="navbar-brand" href="#" style="width: 30%;">
<img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a" alt="TechSnazzy Logo" class="w-100" />
</a>
<!-- <a class="navbar-brand" 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 id=" navbarSupportedContent>
<ul class="navbar-nav mr-auto">
<li class="nav-item">Home</li>
</ul>
</div>
</nav>
</div>
</section>
The toggler is simply getting wrapped to the next line, based on the width of .navbar-brand and this is expected behavior for it to then be left-aligned. If you want the toggler to always be right-aligned, adding the class ml-auto appears to work.
<button class="navbar-toggler ml-auto" ...
See https://getbootstrap.com/docs/4.2/utilities/flex/#auto-margins

Positioning of navbar over image in Bootstrap

I am trying to put an image behind my navbar and have the navbar sit on the lower part of the image. I've tried adding position data to .navbar but it doesn't move it down. In addition, the bottom half of the image below the navbar is cut off. If I add height info to image the full image shows up, but in responsive mode the nav menus and main page overlap.
I've tried putting image as background to .bg-light and as image in html before the navbar.
I'm new to Bootstrap (which btw I really like), and any help appreciated.
.bg-light{
background-image:url("http://www.peterrussell.com/images/header2.jpg")!important;
background-repeat: no-repeat;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<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">
<a class="navbar-brand" href="#">PR</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 mr-auto">
<li class="nav-item dropdown menubar">
<!-- various menu contents omitted for clarity -->
</li>
</ul>
</div>
</nav>

Move inline form to the right in nav [duplicate]

This question already has answers here:
Bootstrap align navbar items to the right
(24 answers)
Closed 4 years ago.
I have the code at https://codepen.io/hby123/project/editor/ANGLnn, how can I move the inline form to the right? I'm using Boostrap 4. I have attempted to use the float-right class, but it's not working. Am I missing something here.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="UTF-8" />
<title>My Site</title>
<!-- Styles -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">My Site</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" style="background-color: lime;">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Features</a>
</div>
<form class="form-inline">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous">
</script>
</body>
</html>
You can give your form a class "form-right" and add the following styles as below.
.form-right{
width: 100% !important;
justify-content: flex-end !important;
}

Bootstrap Nav bar Orientation from LTR to RTL my code attached

I have logo on left side of navbar and menu button on right side I want to change navbar orientation such that logo come to the right side and button for menu on left side my code is,
<nav class="navbar navbar-inverse navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
<img style="max-width:100px; margin-top: -7px;"
src="./Styles/img/seha1.png">
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>abc</li>
<li>abc</li>
<li>abc</li>
<li>abc</li>
</ul>
</div>
</div>
</nav>
I tried one thing to use style navbar pull right on the outer side of this nav tag. and on button navbar pull left it work but result in increase the width of the navbar
Hopes for your suggestions
thanks
You was right, the solution mentioned in the next link do not work for Bootstrap 3:
How to implement RTL bootstrap 4 navbar?
However, I manage to solve your problem using a custom class named navbar-rtl that will customize the CSS style of the navbar for give it a RTL appearance. I hope this can help you:
#media(min-width:768px) {
.navbar-rtl .navbar-header {
float: right;
}
}
.navbar-rtl .navbar-brand {
float: right;
}
.navbar-rtl .navbar-toggle {
float: left;
}
.navbar-rtl .navbar-nav {
float: right;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<nav class="navbar navbar-inverse navbar-default navbar-rtl">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
Navbar
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>abc</li>
<li>abc</li>
<li>abc</li>
<li>abc</li>
</ul>
</div>
</div>
</nav>

Resources