Hamburger button log in goes to the bottom - css

I am trying to create the login from the right side go to the top of the hamburger button menu when it becomes responsive (obviously inside of it with the other tabs). I am assuming that I would have to write a media query or if there is a way to apply a different class in that media query...but I have no idea how to do it. Also, I am using bootstrap for it.
This is what I have so far:
<div class="navbar navbar-inverse navbar-fixed-top" id="navbar">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">HEALTHY LIFE FITNESS</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Clubs
<li>Classes
<li>Training
<li>Pilates
<li>Join
</li>
</ul>
<button type="button" id="login" class="btn btn-default navbar-btn pull-right" style="margin:10px 10px 0px 0px;">Log In</button>
</div>
</div><!--end navbar-->
CSS:
#navbar{background-color: rgb(18,18,28);}
.navbar-toggle .icon-bar:nth-of-type(2) {
top: 1px;
}
.navbar-toggle .icon-bar:nth-of-type(3) {
top: 2px;
}
.navbar-toggle .icon-bar {
position: relative;
transition: all 500ms ease-in-out;
}
.navbar-toggle.active .icon-bar:nth-of-type(1) {
top: 6px;
transform: rotate(45deg);
}
.navbar-toggle.active .icon-bar:nth-of-type(2) {
background-color: transparent;
}
.navbar-toggle.active .icon-bar:nth-of-type(3) {
top: -6px;
transform: rotate(-45deg);
}
JS:
$(document).ready(function () {
$(".navbar-toggle").on("click", function () {
$(this).toggleClass("active")
});
});

Related

Bootstrap navbar collapsing upon clicking an option

I've been trying to figure this out for a while now but I can't seem to be able to locate the problem. Whenever I click on an option from the navbar, it collapses to mobile size (currently set to 992px in bootstrap so its available on tablets), and then return to original size, which turns out that it has a height of 80px after inspecting it. It used to be fine before, but it has suddenly changed after some code edits. I have included some pictures of the problem below.
HTML:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<!-- Navigation logo and dropdown icon -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="css/logo-dream.png" id="logo"></img></a>
</div>
<!-- Navigation Options -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right" id="nav-appearance">
<li id="main-nav">Home <span class="sr-only">(current)</span></li>
<li id="main-nav">About Us</li>
<li id="main-nav">Services</li>
<li id="main-nav">Gallery</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
Below is the CSS code I have used:
/* Main navbar design */
.navbar {
border-radius: 0px;
opacity: 0.95;
background-color: #171717;
border-bottom: 1px solid #9494b8;
margin-bottom: 0 !important;
}
.navbar .navbar-nav {
margin: 15px 0;
}
/* Navbar company logo */
.navbar-brand {
padding: 0;
}
#logo {
margin-left: 40px;
width: 171px;
height: 66px;
margin-top: 8px;
}
/* Navbar options */
#nav-appearance {
font-size: 1.7rem;
margin-right: 40px;
font-family: 'Quicksand', sans-serif;
}
#nav-appearance li {
padding-left: 35px;
}
.collapse {
padding: 0;
}
.navbar-collapse {
padding: 0;
}
/* ======= MEDIA QUERIES FOR NAVIGATION AND HOME ======= */
/* Tablets */
#media (max-width: 991px) {
#nav-appearance {
font-size: 1.7rem;
margin-right: 10px;
}
#nav-appearance a {
padding: 0;
}
#nav-appearance li {
padding: 15px 0 15px 0;
width: 80%;
transform: translateX(-50%);
top: 0;
left: 52%;
}
#main-nav {
border-bottom: 1px solid rgba(55, 55, 55, .95);
}
#logo {
content:url("home-icon-tiny.png");
height: 34px;
width: 34px;
margin-left: 13px;
}
}
/* Mobile */
#media (max-width: 767px) {
#logo {
margin-left: 13px;
}
}
Can anyone see any issues? I hope it's an easy fix.
Update:
From the page its clear that one of the JS files is interfering with the navbar elements. By setting some CSS we can remove the height change, please find below the CSS.
Codepen: here
CSS:
.navbar-brand img{
margin-top:7px;
margin-bottom:7px;
}
/* Navbar company logo */
.navbar-brand {
padding: 0;
height:100%;
}
HTML:
<!-- Navigation logo and dropdown icon -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="css/logo-dream.png" id="logo"></img></a>
</div>
<!-- Navigation Options -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right" id="nav-appearance">
<li id="main-nav">Home <span class="sr-only">(current)</span></li>
<li id="main-nav">About Us</li>
<li id="main-nav">Services</li>
<li id="main-nav">Gallery</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
From the images given I would say that this is a floating elements not having height issue, the solution for this is the clearfix class. so if you change the code as shown below it should not happen. also I removed the div with container-fluid class.
Code: (Do not use)
<!-- Navigation logo and dropdown icon -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="css/logo-dream.png" id="logo"></img></a>
</div>
<!-- Navigation Options -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right" id="nav-appearance">
<li id="main-nav">Home <span class="sr-only">(current)</span></li>
<li id="main-nav">About Us</li>
<li id="main-nav">Services</li>
<li id="main-nav">Gallery</li>
<li>Contact</li>
</ul>
</div>

Making a custom navbar with Bootstrap

I want to make a custom navbar as shown in the image I mocked up.
I've written this so far -
My HTML:
<nav class="navbar navbar-default">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>About</li>
<li>Events</li>
<li>Contact</li>
<li>Play Video</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
My CSS:
.navbar {
background: url(../images/pattern.png) repeat;
background-color: white;
}
.navbar-brand,
.navbar-nav li a {
font-family: 'Josefin Sans';
font-size: 14px;
font-weight: 700;
line-height: 80px;
height: 80px;
padding-top: 0;
-webkit-font-smoothing: antialiased;
text-transform: uppercase;
letter-spacing: .1em;
color: #808080;
}
This looks like a normal navbar should. I don't know how to position the "Play Video" part and the links(home, about etc.) part with a separator in between them. Any ideas on how I should proceed?
Play Video
add any class to this li for example
<li class="play">Play Video</li>
Nex writee this code
.play::before {
color: gray;
content: "|";
float: left;
margin-right: 23px;
}
and put play icon/image in this list item e.g
<li class="play"><img src="play-icon.png"> Play Video</li>
//place play icon path on play-icon.png place
Hope this would help. Thanks

Bootstrap Navbar with dynamic search box

I'm trying to figure out how to make the above code behave well on displays > 768px and < 768px. Right now is working fine for resolutions below 768px, but I can't make it work for resolutions above that.
That's the what I'm trying to do:
Resolution above 768px - Full page (search box with 100% remaining width):
Resolution below 768px (only search box visible):
Code:
.navbar .navbar-form {
padding: 0;
margin-right: 0;
margin-left: 0;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.clear {
width: 1%;
display: table-column;
}
#media(max-width:767px) {
.navbar .navbar-form {
padding-left: 15px;
padding-right: 0;
}
.navbar .navbar-form .input-group {
padding-right: 15px;
}
.navbar .navbar-form .form-control {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand hidden-xs" href="/">Title</a>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for..."/>
<span class="clear hidden-sm hidden-md hidden-lg"></span>
<span class="input-group-btn hidden-xs">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
</form>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>Webpage 1</li>
<li>Webpage 2</li>
</ul>
</div>
</div>
</nav>
Whew, you have yourself a nasty little problem here. It took me a while, but I think I've gotten you a solution together.
First, you need to do the following:
Add display: inline to your form-group
Add display: table to your input-group
Add width: 1% to your input-group-btn
These changes are from this issue here (what you want, but keeps the search bar inside the collapse menu) - Bootstrap 3 - How to maximize input width inside navbar
The next changes you need to make are for when you are above the 768px breakpoint, otherwise it will mess up your collapse menu.
#media(min-width:768px) {
.container-fluid {
display: flex;
}
.navbar-header {
flex: 1;
}
}
Lastly, you need to remove navbar-right from your navbar-form.
Here is a JSFiddle - An embedded snippet is also included.
.navbar .navbar-form {
padding: 0;
margin-right: 0;
margin-left: 0;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.clear {
width: 1%;
display: table-column;
}
#media(max-width:767px) {
.navbar .navbar-form {
padding-left: 15px;
padding-right: 0;
}
.navbar .navbar-form .input-group {
padding-right: 15px;
}
.navbar .navbar-form .form-control {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
}
#media(min-width:768px) {
.container-fluid {
display: flex;
}
.navbar-header {
flex: 1;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand hidden-xs" href="/">Title</a>
<form class="navbar-form" role="search">
<div class="form-group" style="display: inline">
<div class="input-group" style="display: table">
<input type="text" class="form-control" placeholder="Search for..."/>
<span class="clear hidden-sm hidden-md hidden-lg"></span>
<span class="input-group-btn hidden-xs" style="width: 1%">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
</form>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>Webpage 1</li>
<li>Webpage 2</li>
</ul>
</div>
</div>
</nav>

Bootstrap btn-group dropdowns don't work in navbar when collapsed

Basically I am trying to convert the bootstrap navbar into a tool bar. On that toolbar I added some btn-groups with dropdowns which work fine before the media query collapses it. Once it has been collapsed the dropdown-menus cannot be seen, although the element is there and it casts the shadow that it would if it were there. How do I get these drops downs to show up after the collapse?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> INDEX </title>
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="mycss/style.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="datepicker/js/bootstrap-datepicker.js"></script>
</head>
<body>
<nav class="navbar navbar-footer">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#footNav"aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Tool Bar</a>
</div>
<div class="collapse navbar-collapse" id="footNav">
<!-- 1st btn-group (No Dropdown) -->
<div class="btn-group" role="group" aria-label="..." style="margin-right: 7px">
<button type="button" class="btn btn-default">Yesterday</button>
<button type="button" class="btn btn-default">Today</button>
<button type="button" class="btn btn-default">Tomorrow</button>
</div>
<!-- 2st btn-group doesn't work after collapse -->
<div class="btn-group" role="group" aria-label="..." style="margin-right: 7px">
<div class="btn-group dropup" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Past
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Past</li>
<li>This</li>
<li>Next</li>
</ul>
</div>
<button type="button" class="btn btn-default">W</button>
<button type="button" class="btn btn-default">M</button>
<button type="button" class="btn btn-default">3M</button>
<button type="button" class="btn btn-default">Y</button>
</div>
<!-- 3rd btn-group doesn't work after collapse -->
<div class="dropup">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Date Range
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
<div class="input-group" style="padding-bottom: 4px;">
<span class="input-group-addon" >From:</span>
<input class="datepicker" style="height: 30px; width:120px; font-size: 18px; padding:10px;" name="startDate">
</div>
<div class="input-group">
<span class="input-group-addon" >To:</span>
<input class="datepicker2" style="height: 30px; width:120px; font-size: 18px; padding:10px;" name="endDate">
</div>
</ul>
</div>
</div>
</nav>
</body>
</html>
I use the standard bootstrap stuff with the exception of the css changes
/*Calendar tool Bar*/
.navbar {
border-radius: 0px;
}
.dropup{
display: inline-block;
}
.dropdown-menu .input-group .input-group-addon:first-child {
width: 63px;
}
.dropdown-menu {
padding: 4px 4px 4px 4px;
min-width: 30px;
}
.navbar-footer {
background-color: #f8f8f8;
border-color: #e7e7e7;
position: fixed;
bottom: 0px;
width: 100%;
margin-bottom: 0px;
vertical-align: middle;
}
.navbar-footer .navbar-toggle:hover,
.navbar-footer .navbar-toggle:focus {
background-color: #ddd;
}
.navbar-footer .navbar-toggle {
border-color: #ddd;
}
.navbar-footer .navbar-toggle .icon-bar {
background-color: #888;
}
button {
margin-top: 8px;
}
You just need to override the bootstrap .navbar-collapse.in class to make it visible even if it overflows vertically.
.navbar-collapse.in {
overflow-y: visible;
}
Working example.

Transparent Fixed-top Navbar with Boostrap

HTML:
<nav class="navbar navbar-default navbar-fixed-top navbar-transparent">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
Custom CSS (other than the base bootstrap CSS):
.navbar-transparent {
background:transparent;
background-image: none;
border-color: transparent;
}
I looked at other posts on Stack Overflow and here and there on Google, but I can't seem to find a way to make the navbar fully transparent.
So far it looks like this and surely there must be an easier way to set the navbar transparent than to have to edit for all the classes and sub classes and elements within those classes manually?
I guess this works. If anyone has a better workaround, please answer.
#media screen and (min-width: 680px) {
.navbar-transparent {
background: transparent;
background-image: none;
border-color: transparent;
}
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:focus,
.navbar-default .navbar-nav>.active>a:hover {
background: transparent;
background-image: none;
border-color: transparent;
}}
You have to overwrite the ".active" class in your css.
You are already using that (predefined bootstrap) css-class in your code:
< li class="active">< a href="#">Home< / a >< / li>
try:
#navbar ul li.active {
background:transparent;
background-image: none;
border-color: transparent;
}
#navbar ul li:hover { // to overwrite when you :hover the list items
background:transparent;
background-image: none;
border-color: transparent;
}

Resources