Bootstrap hamburger menu mobile - on click will appear and then disappear - html

I've taken a bootstrap theme and the hamburger menu on mobile wasn't working. When the menu is toggled open on mobile, it will open and then quickly close but the menu links are still able to be pressed as if they were there, like they're invisible.
I've checked that the original files had a broken menu and it doesn't. I've tried googling to find out what the problem is but I'm struggling to find an answer.
The only thing I have is that when i use .menu {position: absolute;} then the menu on mobile opens and then quickly closes. When I changed it to .menu {position: relative;} then the menu stays open, but is all right aligned and doesn't look good.
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse.collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand">
<div id="logo" class="pull-left">
<img src="images\robark-Logo.png" alt="Robark Solutions Logo" title="Robark Solutions" width="260" height="90"/>
</div>
</div>
</div>
<div class="navbar-collapse collapse">
<div class="menu">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation">Home</li>
<li role="presentation">About Us</li>
<li role="presentation">Services</li>
<li role="presentation">Portfolio</li>
<li role="presentation">Contact</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
CSS:
.navigation {
background-color:#fff;
padding:0;
}
.navbar-brand {
min-height: 100px;
}
.navbar-brand h1 {
margin-top:9px;
padding-top:5px;
float: left;
font-size: 25px;
color:#333;
text-transform:uppercase;
font-weight:900;
}
.navbar-brand h1 span {
color: #F0A830;
}
.menu {
position: absolute;
overflow: hidden;
font-size:12px;
float:right;
text-transform:uppercase;
font-weight:700;
}
.menu:active ul {
display: block;
}
.menu ul.nav-tabs li {
color:#000;
}
.nav-tabs {
border-bottom: 0;
}
.nav-tabs > li {
float: left;
margin-bottom: 0;
}
.nav-tabs > li > a {
border-radius:0;
color:#333;
padding:30px;
}
.nav-tabs > li > a:hover {
color: #F0A830;
border-color: #fff #fff #fff;
border-radius:0;
background-color:#fff;
transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
}
.nav-tabs > li > a.active {
color: #F0A830;
border-radius:0;
transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
}
#media (max-width: 767px) {
.navbar-brand {
min-height: 85px;
padding-top: 6px;
}
.navbar-brand h1 {
margin-top: 0;
}
.nav-tabs > li {
float: none;
display: block;
}
.menu {
position: absolute;
left: 0;
right: 0;
background: #fff;
}
.menu .collapse {
display: none;
visibility: hidden;
}
.menu-default{
z-index: 1030;
}
.menu:active ul {
display: block;
}
.nav-tabs > li > a {
padding:15px 15px;
border-bottom: 1px solid #f3f3f3;
}
.nav-tabs > li > a:hover {
border-color: #f3f3f3;
}
}
Bootstrap CSS:
#media (min-width: 768px) {
.navbar-header {
float: left;
}
}
.navbar-collapse {
padding-right: 15px;
padding-left: 15px;
overflow-x: visible;
border-top: 1px solid transparent;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
-webkit-overflow-scrolling: touch;
}
.navbar-collapse.in {
overflow-y: auto;
}
#media (min-width: 768px) {
.navbar-collapse {
width: auto;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-collapse.collapse {
display: block!important;
height: auto!important;
padding-bottom: 0;
overflow: visible!important;
visibility: visible!important;
}
.navbar-fixed-top .navbar-collapse,
.navbar-static-top .navbar-collapse,
.navbar-fixed-bottom .navbar-collapse {
padding-right: 0;
padding-left: 0;
}
}
.navbar-fixed-top,
.navbar-fixed-bottom {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
}
.navbar-fixed-top .navbar-collapse,
.navbar-fixed-bottom .navbar-collapse {
max-height: 340px;
}

Related

Creating a Bootstrap navbar collapse overlay menu

I am trying to get an overlay menu when the user clicks on the burger menu it takes up the whole screen, Something like this :
I for some reason cant seem to get it to work at all , i have tried to use examples but it might be because i am not that experienced with bootstrap but it wont overlay the menu at all.
So i have set it up so the burger menu appears at 991px using media queries and it works fine but getting the overlay to pop up is not happening at all.
HTML:
<nav class="navbar navbar-default navbar-fixed-top" id="section1">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" data-target="#myNavbar" data-toggle="collapse" type="button">
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand"><img alt="" src="Images/logo.png" class="img-responsive"></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>
Home
</li>
<li>
About Me
</li>
<li>
Game
</li>
<li>
Me
</li>
<li>
Hobbies
</li>
<li>
Contact Me
</li>
</ul>
</div>
</div>
</nav>
<div class="modal fade" id="nav-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-nav-content">
<div class="modal-nav-body">
<ul>
<li>Brand</li>
<li>About Me</li>
<li>Game</li>
<li>Hobbies</li>
<li>Contact Me</li>
</ul>
</div>
</div>
</div>
</div>
CSS:
#media only screen and (max-width: 991px) {
.navbar-header {
float: none;
}
.navbar-left, .navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-fixed-top {
top: 0;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.modal-nav-content {
width: 100%;
height: auto;
}
.modal-nav-body {
margin-top: 100px;
}
.modal-nav-body ul {
list-style-type: none;
color: white;
margin: 0;
padding: 0;
width: 100%;
}
.modal-nav-body ul li {
text-align: center;
font-size: 130%;
padding: 8px;
text-transform: uppercase;
}
}
You can see the full code here : Fiddle Link
No idea why its not working but i am guessing its something to do with me not using bootstrap correctly ,
Thanks again for all the help
For that you need to use javascript ( or jQuery in my example ) .
First, you need an overlay. I created a div with class .overlay , fixed, full height and width with red background and opacity
Second, you need to position your menu . I positioned in center ( vertically and horizontally ). ( in below 991px media query )
Third, with a little bit of jQuery i made the effect you wanted. You can change/style the code as you please. But what i made for you should be more than enough to help you achieve exactly what you want
Fourth, here on Stack Overflow we don't make free code. We just help you make your code functional. You should try and research more on a subject before posting here for help
See jsFIddle or snippet below
$(".navbar-toggle").on("click", function() {
$(".overlay").fadeIn("slow")
})
$(".overlay").on("click", function() {
$(this).fadeOut();
$(".navbar-collapse").removeClass("in").addClass("collapse")
})
body {
background-color: Black;
}
.navbar-default {
background-color: transparent;
border-top: 0px solid rgba(0, 0, 0, 0.5);
border-bottom: 0px solid rgba(0, 0, 0, 0.5);
border-left: 0px solid rgba(0, 0, 0, 0.5);
border-right: 0px solid rgba(0, 0, 0, 0.5);
-webkit-transition: background-color 200ms linear;
-moz-transition: background-color 200ms linear;
-o-transition: background-color 200ms linear;
-ms-transition: background-color 200ms linear;
transition: background-color 200ms linear;
padding-top: 9px;
padding-bottom: 26px;
}
.navbar.navbar-default .navbar-collapse {
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-nav>li {
border-right: 1px solid white;
padding-left: 14px;
padding-right: 14px;
height: 32px;
}
.navbar-nav {
padding-top: 20px;
}
.navbar-nav>li:last-child {
border: none;
}
.navbar-default .navbar-toggle {
border-color: rgba(0, 0, 0, 0);
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #fff;
}
.navbar-toggle {
margin-top: 19px;
margin-right: 43px;
}
.navbar-default .navbar-nav>li>a {
color: white;
font-size: 15px;
line-height: 1px;
}
.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>li>a:focus {
color: #fff;
background-color: rgba(255, 198, 0, 0);
-webkit-transition: background-color 200ms linear;
-moz-transition: background-color 200ms linear;
-o-transition: background-color 200ms linear;
-ms-transition: background-color 200ms linear;
transition: background-color 200ms linear;
}
.navbar-default .navbar-nav>li>a {
display: inline-block;
position: relative;
padding-bottom: 3px;
}
.navbar-default .navbar-nav>li>a:after {
content: '';
display: block;
margin: auto;
height: 1px;
width: 0px;
background: transparent;
transition: width .4s ease, background-color .4s ease;
margin-top: 12px;
}
.navbar-default .navbar-nav>li>a:hover:after {
width: 100%;
background: #FFC600;
}
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:focus,
.navbar-default .navbar-nav>.active>a:hover {
color: #fff;
background-color: rgba(255, 198, 0, 0);
border-bottom: solid #FFC600;
border-bottom-width: 1px;
height: 29px;
}
#media only screen and (max-width: 991px) {
.navbar-collapse {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.overlay {
position: fixed;
width: 100%;
height: 100%;
background: red;
opacity: 0.5;
left: 0;
top: 0;
display: none;
}
.navbar-header {
float: none;
}
.navbar-left,
.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-fixed-top {
top: 0;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.modal-nav-content {
width: 100%;
height: auto;
}
.modal-nav-body {
margin-top: 100px;
}
.modal-nav-body ul {
list-style-type: none;
color: white;
margin: 0;
padding: 0;
width: 100%;
}
.modal-nav-body ul li {
text-align: center;
font-size: 130%;
padding: 8px;
text-transform: uppercase;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top" id="section1">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" data-target="#myNavbar" data-toggle="collapse" type="button">
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand"><img alt="" src="Images/logo.png" class="img-responsive"></a>
</div>
<div class="overlay">
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>
Home
</li>
<li>
About Me
</li>
<li>
Game
</li>
<li>
Me
</li>
<li>
Hobbies
</li>
<li>
Contact Me
</li>
</ul>
</div>
</div>
</nav>
<div class="modal fade" id="nav-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-nav-content">
<div class="modal-nav-body">
<ul>
<li>Brand</li>
<li>About Me</li>
<li>Game</li>
<li>Hobbies</li>
<li>Contact Me</li>
</ul>
</div>
</div>
</div>
</div>
I would suggest creating a modal and initiating it on a .on('click' function(){}) of the menu item. that way just the backdrop should be good enough to hide everything behind and the focus would be on the modal. If you are not to familiar with bootstrap easier solution would be to use the bootstrap.dialogue library. here is a link to some examples. Please let me know if you have any other questions.
https://nakupanda.github.io/bootstrap3-dialog/

Menu sizing issues

I have a issue with my mega menu sizing. The desktop menu has a hover drop-down mega menu. The mega menus are going to be both 5 column and four column. I cant get the menu to size properly around the columns. currently its set close to what I'd like for the 5 column menu, however there is some text wrapping and id rather have the menu size itself appropriately. The four column has too much white space. I've tried a few things like switching width for max width but that doesn't solve the problem. Id really like to make the mega menu more responsive.
Codepen:https://codepen.io/iamgonge/pen/QpOgZB
desktop nav css:
/* Main Nav syle */
nav {
position: relative;
}
ul.main-nav {
list-style-type: none;
padding: 0px;
font-size: 0px;
max-width: 1000px;
margin: 0 auto;
}
ul.main-nav h2 {
font-size: .9em;
font-weight: 300;
}
ul.main-nav > li {
display: inline-block;
padding: 0;
}
ul.main-nav > li > a {
display: block;
padding: 20px 15px;
position: relative;
color: #fff;
font-size: 15px;
font-weight: 400;
box-sizing: border-box;
}
ul.main-nav > li:hover {
background-color: #f9f9f9;
}
ul.main-nav > li:hover > a {
color: #333;
font-weight: 400;
}
ul.main-nav > li ul.sub-menu-lists {
margin: 0px;
padding: 1px;
list-style-type: none;
display: block;
}
ul.main-nav > li ul.sub-menu-lists > li {
padding: 0 0px;
margin-top: 2px;
}
ul.main-nav > li ul.sub-menu-lists > li > a {
font-size: 14px;
}
.sub-menu-head {
margin: 10px 0;
border-bottom: 1px solid #4F96BA;
width: 100%;
}
/*Media Queries*/
#media only screen and (max-width: 768px) {
#top-logo {
display: block;
max-width: 50%;
margin: 3px auto;
}
.collapse.in {
min-height: 150px;
background-color:#4F96BA;
verflow-y:visible;
}
.sub-menu-head {
color: #fff;
}
nav {
background-color: transparent;
}
ul.main-nav > li > a:after {
display: none;
}
ul.main-nav > li:first-child {
border-radius: 0px;
}
ul.main-nav > li {
display: block;
border-bottom: 1px solid #444;
}
ul.main-nav > li > a {
font-weight: 600;
}
ul.main-nav > li ul.sub-menu-lists > li a {
color: #4F96BA;
;
font-size: 14px;
}
.sub-menu-head {
font-size: 16px;
}
ul.main-nav > li:hover {
background-color: transparent;
}
ul.main-nav > li:hover > a {
text-decoration: none;
font-weight: 600;
}
.sub-menu-block {
padding: 0 30px;
}
.navbar-inverse .navbar-nav .open .dropdown-menu>li>a {
color: #000;
}
#big {
display: none;
}
}
/*end query*/
#media only screen and (min-width: 769px) {
#top-logo, #searchie {
display: none;
}
ul.main-nav {
display: block;
position: relative;
}
.sub-menu-block {
padding: 15px;
}
/* Sub Menu */
ul.main-nav > li > div.sub-menu-block {
visibility: hidden;
background-color: #f9f9f9;
position: absolute;
margin-top: 0px;
width: 100%;
color: #333;
left: 0;
box-sizing: border-box;
z-index: 3;
font-size: 16px;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
opacity: 0;
/*CSS animation applied for sub menu : Slide from Top */
-webkit-transition: all 0.4s ease 0s;
-o-transition: all 0.4s ease 0s;
transition: all 0.4s ease 0s;
-webkit-transform: rotateX(90deg);
-moz-transform: rotateX(90deg);
-ms-transform: rotateX(90deg);
transform: rotateX(90deg);
-webkit-transform-origin: top center;
-ms-transform-origin: top center;
transform-origin: top center;
}
ul.main-nav > li:hover > div.sub-menu-block {
background-color: #f9f9f9;
visibility: visible;
opacity: 1;
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
-ms-transform: rotateX(0deg);
transform: rotateX(0deg);
}
ul.main-nav > li > div.sub-menu-block > * {
-webkit-transition-property: opacity;
-moz-transition-property: opacity;
-o-transition-property: opacity;
transition-property: opacity;
-webkit-transition-duration: 0.4s;
-moz-transition-duration: 0.4s;
-o-transition-duration: 0.4s;
transition-duration: 0.4s;
opacity: 0;
}
ul.main-nav > li:hover > div.sub-menu-block > * {
opacity: 1;
}
.sub-menu-head {
font-size: 20px;
}
/* List Separator: Outer Border */
header.dark ul.main-nav > li > a {
border-right: 1px solid #bbb;
}
header.mega ul.main-nav > li > a {
border-right: 1px solid #666;
}
/* List Separator: Inner Border */
ul.main-nav > li > a:after {
content: '';
width: 1px;
height: 62px;
position: absolute;
right: 0px;
top: 0px;
z-index: 2;
}
header.dark ul.main-nav > li > a:after {
background-color: #777;
}
header.mega ul.main-nav > li > a:after {
background-color: #999;
}
/* Drop Down/Up Arrow for Mega Menu */
ul.main-nav > li > a.mega-menu > span {
display: block;
vertical-align: middle;
}
ul.main-nav > li > a.mega-menu > span:after {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #fff;
content: '';
background-color: transparent;
display: inline-block;
margin-left: 10px;
vertical-align: middle;
}
ul.main-nav > li:hover > a.mega-menu span:after {
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 0px solid transparent;
border-bottom: 5px solid #666;
}
.banners-area {
border-top: 1px solid #ccc;
}
#little {
display: none;
}
}
/*end query*/
/**************Additions****************/
/* 5 Columns */
.col-xs-15,
.col-sm-15,
.col-md-15,
.col-lg-15 {
position: relative;
min-height: 1px;
padding-right: 10px;
padding-left: 10px;
}
.col-xs-15 {
width: 20%;
float: left;
}
#media (min-width: 768px) {
.col-sm-15 {
width: 20%;
float: left;
}
}
#media (min-width: 992px) {
.col-md-15 {
width: 20%;
float: left;
}
}
#media (min-width: 1200px) {
.col-lg-15 {
width: 20%;
float: left;
}
}
html:
<div id="big">
<div class="navbar navbar-default navbar-static-top navbar-main affix-top" data-spy="affix" data-offset-top="50" role="navigation" >
<div class="dark">
<ul class="main-nav">
<li class="top-level-link">
<a class="mega-menu"><span>SOFTWARE</span></a>
<div class="sub-menu-block" id="five-block">
<div class="row">
<div class="col-md-15 col-sm-6">
<h2 class="sub-menu-head">Microsoft Office</h2>
<ul class="sub-menu-lists">
<li class="hover_drop_down">
Microsoft Office 2016<span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Office 2016 Home & Business</li>
</ul>
</li>
<li>Microsoft Office 365 </li>
</ul>
</div>
<div class="col-md-15 col-sm-6">
<h2 class="sub-menu-head">Windows</h2>
<ul class="sub-menu-lists">
<li><a>Microsoft Windows 10 Pro</a></li>
</ul>
</div>
<div class="col-md-15 col-sm-6">
<h2 class="sub-menu-head">SQL Server</h2>
<ul class="sub-menu-lists">
<li><a>Microsoft SQL Server 2016<span class="caret"></span></a></li>
</ul>
</div>
<div class="col-md-15 col-sm-6">
<h2 class="sub-menu-head">Windows Server</h2>
<ul class="sub-menu-lists">
<li><a>Windows Server 2003 R2<span class="caret"></span></a></li>
</ul>
</div>
<div class="col-md-15 col-sm-6">
<h2 class="sub-menu-head">Remote Desktop Services</h2>
<ul class="sub-menu-lists">
<li><a>Remote Desktop Services 2016<span class="caret"></span></a></li>
</ul>
</div>
</div>
</div>
</li>
<li class="top-level-link">
<a class="mega-menu"><span>ELECTRONICS</span></a>
<div class="sub-menu-block">
<div class="row ">
<div class="col-md-3 col-sm-6" >
<h2 class="sub-menu-head">Software Resources</h2>
<ul class="sub-menu-lists" >
<li><a>Software Resources</a></li>
</ul>
</div>
<div class="col-md-3 col-sm-6" >
<h2 class="sub-menu-head">Software Resources</h2>
<ul class="sub-menu-lists" >
<li><a>Software Resources</a></li>
</ul>
</div>
<div class="col-md-3 col-sm-6" >
<h2 class="sub-menu-head">Software Resources</h2>
<ul class="sub-menu-lists" >
<li><a>Software Resources</a></li>
</ul>
</div>
<div class="col-md-3 col-sm-6" >
<h2 class="sub-menu-head">Software Resources</h2>
<ul class="sub-menu-lists" >
<li><a>Software Resources</a></li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<!--Desktop end-->
Can't you just remove the width:100% from the div.sub-menu-block element to remove the extra white-space from the 4-column menu?
Well you can use
white-space:nowrap;
For keeping the names in 1 line take a look here
CSS W3shcool attributes

Navbar Dropdown List Items Appearing Aligned Left Before Animation

I would like my navbar dropdown menu to take up the entire browsing area with the list items centered, and have a brief animation during the transition.
For the animation, I want the .icon-bar hamburger menu to transition to an "X" and for the dropdown menu to have a cubic-bezier transition.
However, the list items first appear aligned left prior to the animation.
Wondering why the list is left-aligned prior to animation.
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: 'Quicksand', sans-serif;
}
body {
margin-top: 60px;
}
#main-wrapper {
display: flex;
flex-direction: column;
min-height: 100%;
}
.container {
margin: 0 auto;
}
.article {
flex: 1;
}
/*START Shrinks the default navbar height*/
.navbar {
//min-height: 30px;
margin: 0px;
width: 100%;
background-color: #444;
//height: 44px;
}
.navbar-nav > li,
.navbar-nav > li > a,
.navbar-nav > li > a:link,
.navbar-nav > li > a:visited {
padding: 4px 5px 0px 5px;
//height: 30px;
color: white;
font-size: 1.1em;
font-weight: 300;
margin: 2px 8px 0 0;
}
/*END*/
.nav.navbar-nav li a:focus,
.nav.navbar-nav li a:active,
.nav.navbar-nav li a:hover {
color: white;
opacity: 0.8;
}
.navbar-toggle {
float: left;
border: none;
margin-top: 10px;
margin-left: 10px;
padding: 4px;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:active,
.navbar-default .navbar-toggle:focus {
background-color: #444;
}
/*Displays navbar dropdown on hover */
ul.nav li.dropdown:hover ul.dropdown-menu {
display: block;
}
.navbar-default .navbar-header .icon-bar {
background-color: white;
width: 22px;
}
.navbar-default .navbar-toggle:hover .icon-bar {
background-color: #EFEFEF;
}
.navbar .navbar-brand {
color: white;
margin: -4px 20px -3px 0;
font-size: 1.7em;
font-family: 'Orbitron', 'Dosis', sans-serif;
}
.navbar .navbar-brand:focus,
.navbar .navbar-brand:hover {
color: white;
opacity: 0.8;
}
.fa-caret-down {
height: 30px;
color: lightGray;
}
/*Change hamburger menu to "x" on click */
.navbar-toggle .icon-bar {
width: 22px;
transition: all 0.4s;
}
.navbar-toggle .top-bar {
transform: rotate(405deg);
transform-origin: 10% 10%;
}
.navbar-toggle .middle-bar {
opacity: 0;
}
.navbar-toggle .bottom-bar {
transform: rotate(-405deg);
transform-origin: 10% 90%;
}
.navbar-toggle.collapsed .top-bar {
transform: rotate(0);
}
.navbar-toggle.collapsed .middle-bar {
opacity: 1;
}
.navbar-toggle.collapsed .bottom-bar {
transform: rotate(0);
}
.navbar.navbar-default .navbar-collapse {
border: none;
box-shadow: none;
}
/*Change Background color of toggle dropdown*/
.collapse.navbar-collapse {
background-color: #444;
min-width: 100%;
min-height: 100%;
}
h3 + p {
line-height: 1.8em;
}
footer {
background-color: #444;
color: white;
height: 250px;
padding: 8px;
}
footer a,
footer a:link,
footer a:visited {
color: white;
text-decoration: none;
}
footer a:hover,
footer a:active,
footer a:focus {
opacity: 0.8;
}
.tagline {
text-align: center;
}
.footer-sub {
border: thin white solid;
margin: 0 2px 7px 0;
max-width: 220px;
}
.fa-plus {
margin-top: 3px;
float: right;
}
.fa-plus:hover {
opacity: 0.8;
cursor: pointer;
}
#location-detail {
display: none;
}
a#location:focus + #location-detail {
display: block;
}
#media (max-width: 992px) {
.navbar-nav > li,
.navbar-nav > li > a,
.navbar-nav > li > a:link,
.navbar-nav > li > a:visited,
.navbar-nav > li > a:hover {
font-size: 1.05em;
}
}
#media (max-width: 767px) {
.navbar .navbar-brand {
position: absolute;
left: 50%;
margin-left: -110px !important;
display: block;
}
.collapse.navbar-collapse {
background-color: #444;
position: fixed;
min-width: 100%;
min-height: 100%;
font-size: 1.3em;
text-align: center;
padding-top: 20px;
transition-property: all;
transition-duration: 0.5s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
}
.collapse.navbar-collapse li {
margin-bottom: 15px;
}
}
<div id="main-wrapper">
<div class="navbar navbar-default navbar-fixed-top">
<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 top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
</button>
<!--<img class="logo" src="../images/eclipse-new.png"/> -->
Eclipse Music
</div> <!-- end of navbar-header -->
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<!--<li><span class="glyphicon glyphicon-home"></span>Home</li>-->
<li>Effects</li>
<li>Guitar</li>
<li>Bass</li>
<li>Amps</li>
<li>Lessons</li>
<li class="dropdown">
About<!-- <i class="fa fa-caret-down"></i>-->
<ul class="dropdown-menu">
<li>Directions</li>
<li>Contact Us</li>
<li>Blog</li>
</ul>
</li>
</ul>
</div> <!-- end of collapse navbar-collapse -->
</div> <!-- end of container -->
</div> <!-- end of navbar navbar-default navbar-fixed-top -->
<div class="article">
<div class="container">
<h2>
Welcome!
</h2>
<br />
</div>
</div> <!-- END of article -->
<footer>
</footer> <!-- END of footer -->
</div> <!-- END of main-wrapper -->
Just add this css in your media query for Xs :
#media (max-width: 767px) {
.navbar .navbar-brand {
position: absolute;
left: 50%;
margin-left: -110px !important;
display: block;
}
.navbar-collapse {
text-align: center;
}
.navbar-collapse li{display:none}
.collapse.navbar-collapse {
background-color: #444;
position: fixed;
min-width: 100%;
min-height: 100%;
font-size: 1.3em;
padding-top: 20px;
transition-property: all;
transition-duration: 0.5s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
}
.collapse.navbar-collapse li {
display:block;
margin-bottom: 15px;
}
}
Here is a bootply with this change : http://www.bootply.com/BQGSpd2kLt
I could be wrong, but it might be this:
.navbar-toggle {
float: left;
border: none;
margin-top: 10px;
margin-left: 10px;
padding: 4px;}
May want those to be something more like this:
.navbar-toggle {
float: right;
border: none;
position: relative;
left: -50%; //or right 50%
text-align: left;
padding: 4px;}

Smaller Than Default Navbar Height Causing Issues

I like the look of a smaller-than-normal navbar height, as it seems to be a popular design trend.
However, this seems to be causing issues when opening a collapse menu.
Here you can see the stages of expanding the collapse navbar-collapse menu. First is my normal navbar with a minimum height of 30px. Then when I click the toggle button, the navbar briefly expands to what appears to be 50px, and finally the full screen menu appears.
This alone isn't a big deal (though I would prefer a smooth transition), however the expand and collapse animations of the menu don't seem to behave as expected with a decreased navbar height.
Any ideas why this is happening? Or, is there something else in my styling that has nothing to do with the navbar height yet is causing the issue?
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: 'Quicksand', sans-serif;
}
body {
margin-top: 60px;
}
#main-wrapper {
display: flex;
flex-direction: column;
min-height: 100%;
}
.container {
margin: 0 auto;
}
.article {
flex: 1;
}
/*START Shrinks the default navbar height*/
.navbar {
min-height: 30px;
//max-height: 40px;
margin: 0px;
width: 100%;
background-color: #444;
}
.navbar-nav > li,
.navbar-nav > li > a,
.navbar-nav > li > a:link,
.navbar-nav > li > a:visited {
padding: 4px 5px 0px 5px;
//height: 30px;
color: white;
font-size: 1.1em;
font-weight: 300;
margin: 2px 8px 0 0;
}
/*END*/
.nav.navbar-nav li a:focus,
.nav.navbar-nav li a:active,
.nav.navbar-nav li a:hover {
color: white;
opacity: 0.8;
}
.navbar-toggle {
float: left;
border: none;
margin-top: 10px;
margin-left: 10px;
padding: 4px;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:active,
.navbar-default .navbar-toggle:focus {
background-color: #444;
}
/*Displays navbar dropdown on hover */
ul.nav li.dropdown:hover ul.dropdown-menu {
display: block;
}
.navbar-default .navbar-header .icon-bar {
background-color: white;
width: 22px;
}
.navbar-default .navbar-toggle:hover .icon-bar {
background-color: #EFEFEF;
}
.navbar .navbar-brand {
color: white;
margin: -4px 20px -3px 0;
font-size: 1.7em;
font-family: 'Orbitron', 'Dosis', sans-serif;
}
.navbar .navbar-brand:focus,
.navbar .navbar-brand:hover {
color: white;
opacity: 0.8;
}
/*Change hamburger menu to "x" on click */
.navbar-toggle .icon-bar {
width: 22px;
transition: all 0.4s;
}
.navbar-toggle .top-bar {
transform: rotate(45deg);
transform-origin: 10% 10%;
}
.navbar-toggle .middle-bar {
opacity: 0;
}
.navbar-toggle .bottom-bar {
transform: rotate(-45deg);
transform-origin: 10% 90%;
}
.navbar-toggle.collapsed .top-bar {
transform: rotate(0);
}
.navbar-toggle.collapsed .middle-bar {
opacity: 1;
}
.navbar-toggle.collapsed .bottom-bar {
transform: rotate(0);
}
.navbar.navbar-default .navbar-collapse {
border: none;
box-shadow: none;
}
/*Change Background color of toggle dropdown*/
.collapse.navbar-collapse {
background-color: #444;
min-width: 100%;
min-height: 100%;
}
h3 + p {
line-height: 1.8em;
}
footer {
background-color: #444;
color: white;
height: 250px;
padding: 8px;
min-width: 100%;
margin: 0 auto;
}
footer a,
footer a:link,
footer a:visited {
color: white;
text-decoration: none;
}
footer a:hover,
footer a:active,
footer a:focus {
opacity: 0.8;
}
.tagline {
text-align: center;
}
.footer-sub {
border: thin white solid;
margin: 0 2px 7px 0;
float: left;
width: 200px;
padding: 5px;
}
.fa-plus {
margin-top: 3px;
float: right;
}
.fa-plus:hover {
opacity: 0.8;
cursor: pointer;
}
#location-detail {
display: none;
}
a#location:focus + #location-detail {
display: block;
}
#media (max-width: 992px) {
.navbar-nav > li,
.navbar-nav > li > a,
.navbar-nav > li > a:link,
.navbar-nav > li > a:visited,
.navbar-nav > li > a:hover {
font-size: 1.05em;
}
}
#media (max-width: 767px) {
.navbar .navbar-brand {
position: absolute;
left: 50%;
margin-left: -110px !important;
display: block;
}
.navbar-collapse {
text-align: center;
}
.navbar-collapse li {
display: none;
}
.collapse.navbar-collapse {
background-color: #444;
position: fixed;
min-width: 100%;
min-height: 100%;
font-size: 1.3em;
text-align: center;
padding-top: 20px;
transition-property: all;
transition-duration: 0.2s;
transition-timing-function: linear;
}
.collapse.navbar-collapse li {
display: block;
margin-bottom: 15px;
}
}
<div class="navbar navbar-default navbar-fixed-top">
<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 top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
</button>
<!--<img class="logo" src="../images/eclipse-new.png"/> -->
Eclipse Music
</div> <!-- end of navbar-header -->
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<!--<li><span class="glyphicon glyphicon-home"></span>Home</li>-->
<li>Effects</li>
<li>Guitar</li>
<li>Bass</li>
<li>Amps</li>
<li>Lessons</li>
<li class="dropdown">
About<!-- <i class="fa fa-caret-down"></i>-->
<ul class="dropdown-menu">
<li>Directions</li>
<li>Contact Us</li>
<li>Blog</li>
</ul>
</li>
</ul>
</div> <!-- end of collapse navbar-collapse -->
</div> <!-- end of container -->
</div> <!-- end of navbar navbar-default navbar-fixed-top -->
Here is my site in progress. I tried copying the styling and markup to JS Fiddle, but it wasn't matching what my webpage shows.

CSS float behaving mysteriously

I'm using Bootstrap 3 to create a mobile responsive website.
There are two top level menus on my webpage. Top menu has a ul floated to right and the menu below that has two components: a ul floated left and a search box floated right.
Although float: right is working on the search box, it is not moving to extreme right as it should; instead it leaves some space from right. I haven't applied any right margin to the search box.
However, when I remove float from the top menu's ul (.settings-menu ul), the search box moves to extreme right. The two menus are in different divs. I can't understand why this is happening. Can someone explain why this happening and recommend a solution? My code is as follows:
<div class="settings-menu"> <!-- Top settings/registration panel -->
<ul>
<li><a>Register</a></li>
<li><a>LogIn</a></li>
<li><a>Wishlist(0)</a></li>
<li><a>My Account</a></li>
</ul>
</div>
<nav class="navbar">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="menu-collapse">
<ul class="nav navbar-nav">
<li>Home Page</li>
<li>Shop by category</li>
<li>Designers</li>
<li>Blog</li>
<li>Contact Us</li>
</ul>
<form class="navbar-form" role="search">
<label for="id_search"></label>
<input type="text" id="id_search" class="form-control" name="search_item" placeholder="Search Store">
<button type="submit" name="search_button" id="id_search_button" class="search-button"></button>
</form>
</div><!-- /.navbar-collapse -->
</nav>
CSS:
body {
font-family: arial;
font-size: 12px;
background: url("images/texture_2.jpg")
}
.settings-menu {
background-color: #E87772;
border-bottom: 4px solid #F1ADAA;
height: 36px;
}
.settings-menu ul {
float: right;
width: auto;
margin-right: 5%;
}
.settings-menu ul li{
display: inline-block;
padding: 5px;
list-style: none;
}
.settings-menu ul li a{
color: #fff;
font-size: 14px;
}
nav {
background-color: #fff;
width: 100%;
}
nav ul {
float: left;
}
.navbar-nav > li { /*over-riding bootstrap's classes */
display: inline-block;
padding: 7px;
margin-right: 7px;
}
.navbar-nav > li > a{
font-size: 16px;
color: rgb(80,80,80);
padding: 0px;
padding-bottom: 7px;
}
.navbar-nav > li > a:hover{
background-color: #fff;
}
.navbar-nav > li > a:after{
background: none repeat scroll 0 0 #e87772;
bottom: 0;
content: " ";
height: 2px;
left: 50%;
position: absolute;
transition: all 0.25s ease-in-out 0s;
width: 0;
}
.navbar-nav > li > a:hover:after, .navbar-nav > li > a:focus:after {
left: 0;
width: 100%;
}
.navbar-form {
float: right;
display: inline-block;
margin-top: 0;
width: 285px;
height: 45px;
}
.navbar-form .search-button {
background: url("images/icon-search-button.png") no-repeat;
border-radius: 100%;
background-color: #E87772;
height: 38px;
width: 38px;
background-position: center;
border: none;
transition-property: height, width;
transition-duration: 50ms;
transition-timing-function: ease-in-out;
}
.navbar-form .search-button:hover {
height: 40px;
width: 40px;
}
.navbar-form .cart-button {
background: url("images/icon-cart-link.png") no-repeat;
border-radius: 100%;
background-color: #E87772;
height: 38px;
width: 38px;
background-position: center;
border: none;
transition-property: height, width;
transition-duration: 50ms;
transition-timing-function: ease-in-out;
}
.navbar-form .cart-button:hover {
height: 40px;
width: 40px;
}
#id_search { /* for text-box */
border-radius: 0px;
border-right: none;
border-left: none;
border-top: 1px solid #DDDDDD;
border-bottom: 1px solid #DDDDDD;
box-shadow: none;
margin-top: 5px;
}
#search-box {
float: right;
}
.navbar-collapse.collapse have default padding by bootstrape. try this Demo
.navbar-collapse.collapse{
padding-right :0 !important;
}