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;
}
Related
My dropdown menu goes behind the image slider part of my website. How can I get the dropdown in front of the image slider? I have also some other div's but they go like normally behind the dropdown menu of the Navbar. So I like to have the dropdown in front of the div of the image slider I made. I hope someone can help me
<--code html-->
<nav>
<div class="logo">
<div id="myMenu">
<div class="logo-navbar">
<nav>
<img src="images/logo-groot.png" height="80" />
</nav>
</div>
</div>
</div>
<label for="btn" class="icon">
<span class="fa fa-bars"></span>
</label>
<input type="checkbox" id="btn">
<ul>
<li>Home</li>
<li>
<label for="btn-2" class="show">Assortiment</label>
Assortiment
<input type="checkbox" id="btn-2">
<ul>
<li>Knalvuurwerk</li>
<li>Siervuurwerk</li>
<li>Kindervuurwerk</li>
</ul>
</li>
<li>Contact</li>
</ul>
</nav>
<div class="container">
<h1 id="headline">Nog <span id="days"></span> dagen tot start online vuurwerkverkoop</h1
<div id="countdown">
</div>
</div>
<div class="slideshow-container">
<!-- Full-width images with number and caption text -->
<div class="mySlides fade">
<a href="selectie.html"><img src="images/pyropapel-actie.png" style="width:100%">
</div>
<div class="mySlides fade">
<a href="contact.html"><img src="images/logo-groot.png" style="width:100%">
</div>
<div class="mySlides fade">
<a href="geschiedenis.html"><img src="images/logo-groot.png" style="width:100%">
</div>
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<!-- The dots/circles -->
<div class="dots" style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
</div>
<-- css -->
nav{
background: #151515;
}
nav:after{
content: '';
clear: both;
display: table;
}
nav .logo{
float: left;
line-height: 70px;
padding-left: 60px;
}
nav ul{
float: right;
margin-right: 4px;
list-style: none;
position: relative;
}
nav ul li{
float: left;
display: inline-block;
background: #151515;
margin: 5 5px;
}
nav ul li a{
color: white;
line-height: 70px;
text-decoration: none;
font-size: 18px;
padding: 8px 15px;
}
nav ul li a:hover{
color: white;
border-radius: 5px;
box-shadow: 0 0 5px #000000,
0 0 10px #0a0a0a;
}
nav ul ul li a:hover{
box-shadow: none;
}
nav ul ul{
position: absolute;
top: 90px;
border-top: 3px solid red;
opacity: 0;
visibility: hidden;
transition: top .3s;
}
nav ul ul ul{
border-top: none;
}
nav ul li:hover > ul{
top: 70px;
opacity: 1;
visibility: visible;
}
nav ul ul li{
position: relative;
margin: 0px -20px;
width: 175px;
float: none;
display: list-item;
border-bottom: 1px solid rgba(0,0,0,0.3);
text-align:center;
}
nav ul ul li a{
line-height: 50px;
}
nav ul ul ul li{
position: relative;
top: -60px;
left: 150px;
}
.show,.icon,input{
display: none;
}
.fa-plus{
font-size: 15px;
margin-left: 40px;
}
#media all and (max-width: 968px) {
nav ul{
margin-right: 0px;
float: left;
}
nav .logo{
padding-left: 30px;
width: 100%;
}
.show + a, nav > ul{
display: none;
}
nav ul li,nav ul ul li{
display: block;
width: 100%;
}
nav ul li a:hover{
box-shadow: none;
}
.show{
display: block;
color: white;
font-size: 18px;
padding: 0 15px;
line-height: 70px;
cursor: pointer;
}
.show:hover{
color: white;
border-radius:5px;
}
.icon{
display: block;
color: white;
position: absolute;
top: 25;
right: 40px;
line-height: 70px;
cursor: pointer;
font-size: 25px;
}
nav ul ul{
top: 70px;
border-top: 0px;
float: none;
position: static;
display: none;
opacity: 1;
visibility: visible;
}
nav ul ul a{
padding-left: 40px;
}
nav ul ul ul a{
padding-left: 80px;
}
nav ul ul ul li{
position: static;
}
[id^=btn]:checked + ul{
display: block;
}
nav ul ul li{
border-bottom: 0px;
}
span.cancel:before{
content: '\f00d';
}
}
.slideshow-container {
position: relative;
margin: auto;
background-color: rgba(0, 0, 0, 1);
width:75%;
}
/* Hide the images by default */
.mySlides {
display: none;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
align-items: center;
top: 50%;
width:auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
background-color: #bbb;
}
.active, .dot:hover {
background-color: #717171;
}
.dots{
background-color: rgba(23, 14, 13, 0.97);
width:75%;
align-items:center;
margin:auto;
padding-top: 20px;
margin-top:-24px;
}
/* Fading animation */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
#-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
#keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
I have been sitting for 4 hours now trying to make my nav display dropdown-links vetically but it continues to show them horizontally instead. I can´t figure out why this is happening or how to fix it.
I would appreciate it very much if some kind soul could tell me what I am doing wrong. I have a sneaking suspecion this is caused due to my settings for the nav (it changes size at a certain width) but I am not sure...
I have ripped my nav from my website and thrown everything into codepen, but even after several attempts to figure out where the problem starts - nothing! It displays "link1" right below and then just adds "link2" and "link3" to the right of it, instead of under
Please help?
Codepen: https://codepen.io/Pinchofginger/pen/BJJQgZ
If there are any oddities in the CSS it´s because I have a dropdown menu for mobile that display when you press an icon... it is not currently working either, but that a question for another time.
My HTML
<header class="mainheader">
<section id="baggrund">
<div id="mainlogo">
Sønderborg
<p> og omegns</p> Kattelaug<br />
<img class="vector" src="billeder/udklip.png" alt="Kattesilhuet"></div>
<nav>
<input type="checkbox" id="menu-checkbox" role="button" />
<label for="menu-checkbox" id="menu-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</label>
<div id="nav_wrap">
<ul id="menu">
<li>Forside</li>
<li>Adopter en kat</li>
<li>Tilløber katte</li>
<li> Kattens pleje</li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">
Kontakt</a><div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
</ul></div>
</nav>
</section>
</header>
MY CSS
/* small nav */
#media screen and (max-width: 61em) {
#menu li {
width: 20%;
}
#menu li a {
font-size: 0.9em;
width:100%;
color:red;}
#menu ul {width:100%;}
/*sidebar*/
body#index .sidemenu .sidebar1 {padding: 0 0 0 0;}
body#index #Mega {width: 96%; height:80px;}
body#index .sidemenu .sidebar1 h3 {font-size: 0.9em;}
}
/* stor nav*/
#media screen and (min-width: 61em) {
#menu li {
width: 20%;
}
#menu li a {
font-size: 1.2em;
width:100%;
color: #505050;
}} /*slut, stor*/
#menu li {
display: inline-block;
background: none;
padding: 5px 5px 5px 5px;
}
#menu li a {
text-transform: uppercase;
transition: all .5s ease;
text-decoration: none;
text-align: center;
line-height: 55px;
display: inline-block;}
.sidemenu .pleje {font-size: 0.9em; display:inline-block }
.sidemenu .pleje h3 {color: orange;}
#mainlogo {
display: block;
}
.mainheader {
width: 100%;
}
#bannerkat { display: none;}
#menu-button { display: none;}
#menu {
display: block;
border-radius: 0;
text-align: center;
position: relative;
}
/* Navigations menuen (links osv) */
#nav_wrap {
background: #f9f4ea;
width: 100%;
white-space: nowrap;
float: left;
height: 60px;
position: relative;
margin-top: 144px;
bottom: 0;
/* overflox:hidden; */
z-index: 9999;
opacity: .9;
box-shadow: 0px 1px 4px beige;
padding: 0;
}
li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block;
}
/* højde for billed-sektion*/
.mainheader section {
min-height: 204px;
}
#mainlogo {
font-size: 37px;
color: white;
border: 7px solid white;
display: inline-block;
padding: 10px;
position: absolute;
height: 123px;
/* hvid boks*/
line-height: 25px;
top: 202px;
margin-top: -180px;
left: 50%;
width: 600px;
text-align: center;
margin-left: -300px;
text-shadow: 1px 2px 1px #000;
box-shadow: 1px 2px 1px #000;
}
/* og omegns */
#mainlogo p {
font-size: 20px;
padding: 5px;
}
.vector {
width: 60px;
margin-left: -450px;
margin-top: -36px;
}
.mainheader {
margin-top: 10px;
}
Change line 42 in css: "menu li a" to Display: block instead of Display: inline-block:
#menu li a {
text-transform: uppercase;
transition: all .5s ease;
text-decoration: none;
text-align: center;
line-height: 55px;
display: block;
}
Everything seems to work fine when the browser size is large... but when the dropdown on the right is open and the user shrinks the browser size... the dropdown on the right changes width and the user image floats from right to left.
I have tried given it a fixed width... it fixed the width but still floats left. Seems to be something with bootstrap not my custom styling
JSFiddle Demo
img.logo {
margin-top: -12px;
height: 55px;
}
.navigation .top-nav .navbar-inverse li a {
height: 60px;
line-height: 30px;
}
.navigation .top-nav a,
.navigation .top-nav .navbar-nav>li>a {
color: white;
}
.navbar-inverse .navbar-nav>.user.open>a,
.navbar-inverse .navbar-nav>.user.open>a:hover,
.navbar-inverse .navbar-nav>.user.open>a:focus {
background-color: #282c36;
}
#profile-img {
height: 40px;
width: 40px;
border-radius: 40px;
margin-right: 10px;
position: relative;
bottom: 3px;
}
.user .dropdown-menu {
background-color: #282c36;
border: 0;
text-align: center;
color: white;
min-width: 100px !important;
}
.user .dropdown-menu li {
padding: 5px 0 5px 0;
margin: 0 15px 0 15px;
height: 50px !important;
background-color: #282c36 !important;
color: white !important;
}
.user .dropdown-menu li a {
height: 100% !important;
background-color: #282c36 !important;
color: white !important;
}
.user .dropdown-menu li:hover,
.user .dropdown-menu li a:hover {
cursor: pointer;
background-color: #282c36 !important;
color: white;
}
.navigation .top-nav .navbar-inverse>ul>li {
padding-left: 8px;
}
.top-nav .navbar-collapse.collapse {
display: block!important;
}
.top-nav .navbar-nav>li,
.navbar-nav {
float: left !important;
}
.top-nav .navbar-nav.navbar-right:last-child {
margin-right: -15px !important;
}
.top-nav .navbar-right {
position: absolute !important;
right: 15px !important;
}
#media(max-width: 767px) {
.navigation .top-nav .navbar-inverse {
height: 60px;
}
.top-nav .navbar-right {
float: right !important;
position: absolute !important;
top: -8px !important;
right: 15px !important;
}
.top-nav .cart a {
margin-top: 6px;
}
.top-nav .user {
top: 5px;
}
.top-nav .cart {
padding-top: -5px !important;
}
.top-nav .user .dropdown-menu {
z-index: 999 !important;
background-color: #282c36 !important;
position: relative !important;
top: -5px;
}
.top-nav .navbar-header {
height: 60px !important;
}
.navigation .top-nav .navbar-inverse a {
line-height: 30px;
}
}
<script type="text/javascript" src="//code.jquery.com/jquery-2.2.4.js"></script>
<link rel="stylesheet" type="text/css" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script type="text/javascript" src="https://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<div class="top-nav">
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="logo" />
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<li class="dropdown user">
<img src="http://freefacebookhakken.nl/img/profile-pic.png" id="profile-img"><i class="glyphicon glyphicon-chevron-down" id="profile-toggle"></i>
<ul class="dropdown-menu">
<li>Testing </li>
<li>Contact us</li>
<li>Test</li>
</ul>
</li>
</ul>
</div>
</nav>
</div>
First screen shot
Second Screen shot
This css update will fix your width issue.
.navbar-right, .dropdown, .dropdown-menu {
width: 130px;
}
JSFiddle Link
Looks like you have a few other issues though (nav bar edges straighten out when short, line appears in nav bar when short, height of drop-down lines change when short).
Bootstrap's navbar classes have media queries that adjust positioning so they integrate with the toggleable mobile navbar. But you aren't using it and the navbar-right class used on the that the dropdown is in has a media query that adjusts positioning at max width:767px that likely causes the issue you're seeing.
You will have to either change that media query in the bootstrap css file (alternatively add your own css to prevent those media query changes, but may be messy. As an example, I tried in the jsfiddle by adding .user{min-width: 160px;} which partially solved your issue, you'll see what I mean by adding that), or use a dropdown with your own classes (you can easily start with one of these).
Find the code snippet for your question. Thanks.
.top-nav {
float: left;
width: 100%;
clear: both;
}
img.logo {
margin-top: -12px;
height: 55px;
}
.navigation .top-nav .navbar-inverse li a {
height: 60px;
line-height: 30px;
}
.navigation .top-nav a,
.navigation .top-nav .navbar-nav>li>a {
color: white;
}
.navbar-inverse .navbar-nav>.user.open>a,
.navbar-inverse .navbar-nav>.user.open>a:hover,
.navbar-inverse .navbar-nav>.user.open>a:focus {
background-color: #282c36;
}
#profile-img {
height: 40px;
width: 40px;
border-radius: 40px;
margin-right: 10px;
position: relative;
bottom: 3px;
}
.user .dropdown-menu {
background-color: #282c36;
border: 0;
text-align: center;
color: white;
min-width: auto !important;
}
.user .dropdown-menu li {
padding: 5px 0 5px 0;
margin: 0 15px 0 15px;
height: 50px !important;
background-color: #282c36 !important;
color: white !important;
}
.user .dropdown-menu li a {
height: 100% !important;
background-color: #282c36 !important;
color: white !important;
}
.user .dropdown-menu li:hover,
.user .dropdown-menu li a:hover {
cursor: pointer;
background-color: #282c36 !important;
color: white;
}
.navigation .top-nav .navbar-inverse>ul>li {
padding-left: 8px;
}
.top-nav .navbar-collapse.collapse {
display: block!important;
}
.top-nav .navbar-nav>li,
.navbar-nav {
float: left !important;
}
.top-nav .navbar-nav.navbar-right:last-child {
margin-right: -15px !important;
}
.top-nav .navbar-right {
position: absolute !important;
right: 15px !important;
}
#media(max-width: 767px) {
.navigation .top-nav .navbar-inverse {
height: 60px;
}
.top-nav .navbar-right {
float: right !important;
position: absolute !important;
top: -8px !important;
right: 15px !important;
}
.top-nav .cart a {
margin-top: 6px;
}
.top-nav .user {
top: 5px;
}
.top-nav .cart {
padding-top: -5px !important;
}
.top-nav .user .dropdown-menu {
z-index: 999 !important;
background-color: #282c36 !important;
position: relative !important;
top: 50px;
}
.top-nav .navbar-header {
height: 60px !important;
}
.navigation .top-nav .navbar-inverse a {
line-height: 30px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="top-nav">
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-header pull-left">
<a class="navbar-brand" href="#">
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="logo" />
</a>
</div>
<div class="pull-right">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown user">
<img src="http://freefacebookhakken.nl/img/profile-pic.png" id="profile-img"><i class="glyphicon glyphicon-chevron-down" id="profile-toggle"></i>
<ul class="dropdown-menu">
<li>Testing </li>
<li>Contact us</li>
<li>Test</li>
</ul>
</li>
</ul>
</div>
</nav>
</div>
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;}
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.