Bootstrap - My mobile toggle button appears in all viewports? - html

I have been watching tutorials on creating a responsive navbar and one thing I am trying to create is a responsive menu button. I have created the button as you can see here:
http://jsfiddle.net/nickmadd/LvhCh/4/
The HTML
<nav class="navbar navbar-default affix-top nav-links" data-spy="affix" data-offset-top="100" role="navigation">
<div class="container">
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
</button>
<div class="navbar-header"> <a class="navbar-brand" href="/"><img src="media/img/nav-logo.png" alt="Driven Car Sales Logo" class="img-rounded logo-nav navbar-brand" /></a>
</div>
<div class="nav-collapse navbar-responsive-collapse" data-toggle="collapse" data-target=".navbar-nav">
<ul class="nav navbar-nav">
<li>Used Cars
</li>
<li>Get Finance
</li>
<li class="dropdown">About Driven<strong class="caret"></strong>
<ul class="dropdown-menu">
<li> <a href "#">The Team</a>
</li>
<li> <a href "#">Our Partners</a>
</li>
</ul>
<!--Drop Down End-->
</li>
<li>How To Find Us
</li>
<li>Contact Us
</li>
</ul>
</div>
</div>
</nav>
The CSS
.navbar-toggle {
display: block;
}
.logo-nav {
height: 2.3em;
width: auto;
}
.brand {
font-size: 2em;
margin: 20px 0 25px;
}
.navbar-brand {
opacity: 0;
color: #ff0066;
-webkit-transition:opacity 0.3s ease-in;
-moz-transition:opacity 0.3s ease-in;
-o-transition:opacity 0.3s ease-in;
transition: opacity 0.3s ease-in;
margin-left: 0px;
}
.navbar {
border-radius: 0px;
border-left: none;
border-right: none;
}
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar- default .navbar-nav>.open>a:focus {
color: #fff;
background-color: #DD3B4D;
}
.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus {
color: #fff;
}
.dropdown-menu {
color: #fff;
background-color: #DD3B4D;
}
.dropdown-menu>li>a {
color: #fff;
}
nav.affix {
top: 0;
width: 100%;
z-index: 1000;
}
nav.affix .navbar-brand {
opacity: 1;
height: 2.3em;
width: auto;
}
.navbar-header {
width: 0px;
-webkit-transition:width .4s ease-in-out;
-moz-transition:width .4s ease-in-out;
-o-transition:width .4s ease-in-out;
transition:width .4s ease-in-out;
margin: 0 1em 0 1em
}
nav.affix .navbar-header {
width: 8em;
-webkit-transition: width .4s ease-in-out;
-moz-transition: width .4s ease-in-out;
-o-transition: width .4s ease-in-out;
transition: width .4s ease-in-out;
margin: 0 1em 0 0;
}
.nav-links {
font: 600 15px/1.5'Arimo';
}
.navbar-nav > li:last-child {
border-right: 1px solid #475d88;
}
ul.nav a:hover {
color: #fff !important;
background-color: #DD3B4D !important;
-webkit-transition: background-color 0.6s ease;
-moz-transition: background-color 0.6s ease;
-o-transition: background-color 0.6s ease;
transition: background-color 0.6s ease;
}
nav.affix .navbar-brand {
display: inline-block;
}
The issue is that when it opens in the browser it is still there even in a large viewpoint. I need it to appear when it get's towards mobile size. I could go and do this with media queries but I'm sure that bootstrap is meant to do this for you?
Am I missing something?

It's because you are overriding the Bootstrap css with your own css, at the very top of your css you have:
.navbar-toggle {
display: block;
}
which tells ".navbar-toggle" to always show. Remove this and it will show/hide correctly. Also these docs might be useful if you have any more trouble.
Update
Updated fiddle with correct syntax. The main issue was that you had .nav-collapse instead of .navbar-collapse.

You are missing the hidden class which is a large part of bootstrap's responsiveness on different viewport sizes. Check out this bootply
Your button works fine when you make it hidden on large and medium viewports:
<button class="navbar-toggle hidden-md hidden-lg" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
</button>
Read about the sizes and hiding here. You can add that class to everything in bootstrap, so move it around if you want to hide more or less.

Related

Bootstrap 4 navbar lost it's background during coding

I'm new to Boostrap, and in an attempt to make a navbar more responsive for all screens and add some effects somewhere along the way my navbar lost its background color.
I've tried explicitly taking the navbar-light class and changed it's colour, but it doesn't seem to work.
The HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>
Navbar
</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body>
<header class="header_area">
<div class="main_menu">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container box_1620">
<a class="navbar-brand logo_h" href="index.html"><h2>Brand</h2></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="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div
class="collapse navbar-collapse offset"
id="navbarSupportedContent"
>
<ul class="nav navbar-nav menu_nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pricing.html">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="gallery.html">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</header>
<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.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>
</body>
</html>
The CSS:
.header_area {
padding: 0px;
border: 0px;
border-width: 0px;
position: absolute;
width: 100%;
top: 0;
left: 0;
z-index: 99;
-webkit-transition: background 0.4s, all 0.3s linear;
-o-transition: background 0.4s, all 0.3s linear;
transition: background 0.4s, all 0.3s linear;
}
.header_area .navbar {
padding: 0px;
border: 0px;
border-width: 0px;
}
.header_area .navbar .nav .nav-item {
margin-right: 45px;
}
.header_area .navbar .nav .nav-item .nav-link {
font: 500 12px/100px "Roboto", sans-serif;
text-transform: uppercase;
color: #222222;
padding: 0px;
display: inline-block;
}
.header_area .navbar .nav .nav-item .nav-link:after {
display: none;
}
.header_area .navbar .nav .nav-item:hover .nav-link,
.header_area .navbar .nav .nav-item.active .nav-link {
color: #ff2f92;
}
.header_area .navbar .nav .nav-item.submenu {
position: relative;
}
.header_area .navbar .nav .nav-item.submenu ul {
border: none;
padding: 0px;
border-radius: 0px;
-webkit-box-shadow: none;
box-shadow: none;
margin: 0px;
background: #fff;
}
#media (min-width: 992px) {
.header_area .navbar .nav .nav-item.submenu ul {
position: absolute;
top: 120%;
left: 0px;
min-width: 200px;
text-align: left;
opacity: 0;
-webkit-transition: all 300ms ease-in;
-o-transition: all 300ms ease-in;
transition: all 300ms ease-in;
display: block;
border: none;
padding: 0px;
border-radius: 0px;
}
}
.header_area .navbar .nav .nav-item.submenu ul:before {
content: "";
width: 0;
height: 0;
border-style: solid;
border-color: #eeeeee transparent transparent transparent;
position: absolute;
right: 24px;
top: 45px;
z-index: 3;
opacity: 0;
-webkit-transition: all 400ms linear;
-o-transition: all 400ms linear;
transition: all 400ms linear;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item {
display: block;
float: none;
margin-right: 0px;
border-bottom: 1px solid #ededed;
margin-left: 0px;
-webkit-transition: all 0.4s linear;
-o-transition: all 0.4s linear;
transition: all 0.4s linear;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item .nav-link {
line-height: 45px;
color: #222222;
padding: 0px 30px;
-webkit-transition: all 150ms linear;
-o-transition: all 150ms linear;
transition: all 150ms linear;
display: block;
margin-right: 0px;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item:last-child {
border-bottom: none;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item:hover .nav-link {
background: #ff2f92;
color: #fff;
}
#media (min-width: 992px) {
.header_area .navbar .nav .nav-item.submenu:hover ul {
visibility: visible;
opacity: 1;
top: 100%;
}
}
.header_area .navbar .nav .nav-item.submenu:hover ul .nav-item {
margin-top: 0px;
}
.header_area .navbar .nav .nav-item:last-child {
margin-right: 0px;
}
.header_area + section,
.header_area + row,
.header_area + div {
margin-top: 100px;
}
.header_area.navbar_fixed .main_menu {
position: fixed;
width: 100%;
top: -70px;
left: 0;
right: 0;
background: #fff;
-webkit-transform: translateY(70px);
-ms-transform: translateY(70px);
transform: translateY(70px);
-webkit-transition: background 500ms ease, -webkit-transform 500ms ease;
transition: background 500ms ease, -webkit-transform 500ms ease;
-o-transition: transform 500ms ease, background 500ms ease;
transition: transform 500ms ease, background 500ms ease;
transition: transform 500ms ease, background 500ms ease,
-webkit-transform 500ms ease;
-webkit-transition: transform 500ms ease, background 500ms ease;
-webkit-box-shadow: 0px 3px 16px 0px rgba(0, 0, 0, 0.1);
box-shadow: 0px 3px 16px 0px rgba(0, 0, 0, 0.1);
}
I want to know why this happened, where I went wrong and a solution to my problem.
Your error is here:
<nav class="navbar navbar-expand-lg navbar-light">
In bootstrap 4 we use bg-light instead of navbar-light like below...
If you want another colors, check the documentation here: https://getbootstrap.com/docs/4.0/components/navbar/#color-schemes
.header_area {
padding: 0px;
border: 0px;
border-width: 0px;
position: absolute;
width: 100%;
top: 0;
left: 0;
z-index: 99;
-webkit-transition: background 0.4s, all 0.3s linear;
-o-transition: background 0.4s, all 0.3s linear;
transition: background 0.4s, all 0.3s linear;
}
.header_area .navbar {
padding: 0px;
border: 0px;
border-width: 0px;
}
.header_area .navbar .nav .nav-item {
margin-right: 45px;
}
.header_area .navbar .nav .nav-item .nav-link {
text-transform: uppercase;
color: #222222;
padding: 0px;
display: inline-block;
}
.header_area .navbar .nav .nav-item .nav-link:after {
display: none;
}
.header_area .navbar .nav .nav-item:hover .nav-link,
.header_area .navbar .nav .nav-item.active .nav-link {
color: #ff2f92;
}
.header_area .navbar .nav .nav-item.submenu {
position: relative;
}
.header_area .navbar .nav .nav-item.submenu ul {
border: none;
padding: 0px;
border-radius: 0px;
-webkit-box-shadow: none;
box-shadow: none;
margin: 0px;
background: #fff;
}
#media (min-width: 992px) {
.header_area .navbar .nav .nav-item.submenu ul {
position: absolute;
top: 120%;
left: 0px;
min-width: 200px;
text-align: left;
opacity: 0;
-webkit-transition: all 300ms ease-in;
-o-transition: all 300ms ease-in;
transition: all 300ms ease-in;
display: block;
border: none;
padding: 0px;
border-radius: 0px;
}
}
.header_area .navbar .nav .nav-item.submenu ul:before {
content: "";
width: 0;
height: 0;
border-style: solid;
border-color: #eeeeee transparent transparent transparent;
position: absolute;
right: 24px;
top: 45px;
z-index: 3;
opacity: 0;
-webkit-transition: all 400ms linear;
-o-transition: all 400ms linear;
transition: all 400ms linear;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item {
display: block;
float: none;
margin-right: 0px;
border-bottom: 1px solid #ededed;
margin-left: 0px;
-webkit-transition: all 0.4s linear;
-o-transition: all 0.4s linear;
transition: all 0.4s linear;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item .nav-link {
line-height: 45px;
color: #222222;
padding: 0px 30px;
-webkit-transition: all 150ms linear;
-o-transition: all 150ms linear;
transition: all 150ms linear;
display: block;
margin-right: 0px;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item:last-child {
border-bottom: none;
}
.header_area .navbar .nav .nav-item.submenu ul .nav-item:hover .nav-link {
background: #ff2f92;
color: #fff;
}
#media (min-width: 992px) {
.header_area .navbar .nav .nav-item.submenu:hover ul {
visibility: visible;
opacity: 1;
top: 100%;
}
}
.header_area .navbar .nav .nav-item.submenu:hover ul .nav-item {
margin-top: 0px;
}
.header_area .navbar .nav .nav-item:last-child {
margin-right: 0px;
}
.header_area + section,
.header_area + row,
.header_area + div {
margin-top: 100px;
}
.header_area.navbar_fixed .main_menu {
position: fixed;
width: 100%;
top: -70px;
left: 0;
right: 0;
background: #fff;
-webkit-transform: translateY(70px);
-ms-transform: translateY(70px);
transform: translateY(70px);
-webkit-transition: background 500ms ease, -webkit-transform 500ms ease;
transition: background 500ms ease, -webkit-transform 500ms ease;
-o-transition: transform 500ms ease, background 500ms ease;
transition: transform 500ms ease, background 500ms ease;
transition: transform 500ms ease, background 500ms ease,
-webkit-transform 500ms ease;
-webkit-transition: transform 500ms ease, background 500ms ease;
-webkit-box-shadow: 0px 3px 16px 0px rgba(0, 0, 0, 0.1);
box-shadow: 0px 3px 16px 0px rgba(0, 0, 0, 0.1);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>
Navbar
</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body>
<header class="header_area">
<div class="main_menu">
<nav class="navbar navbar-expand-lg bg-light">
<div class="container box_1620">
<a class="navbar-brand logo_h" href="index.html"><h2>Brand</h2></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="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div
class="collapse navbar-collapse offset"
id="navbarSupportedContent"
>
<ul class="nav navbar-nav menu_nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pricing.html">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="gallery.html">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</header>
<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.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>
</body>
</html>
The problem about the huge navbar is here:
.header_area .navbar .nav .nav-item .nav-link {
font: 500 12px/100px "Roboto", sans-serif;
text-transform: uppercase;
color: #222222;
padding: 0px;
display: inline-block;
}
What's doing that is the line:
font: 500 12px/100px "Roboto", sans-serif;
You have to put a smaller font, or just delete it and it'll do the trick!

Boostrap img reposive , not getting smaller in the navbar

Hi guys so i have a problem were i have my logo on the left hand side of my navbar and my navgation on the right hand side. Now as i am shrinking the screen i am trying to get the image to appear smaller so that the nav text and the image dont overlap each other.So basically a responsive design. However for some reason it does not seem to work at all,
I have used the class="img-fluid which boostrap says to use but it dosen't seem to work at all on the logo, so any help on this matter would be great
Fiidle Link : Here
I have used float right on the nav bar and maybe thats what messes it up? but again i am not so sure how to get the image to be resposive and get smaller as the page shrinks
P.S As you can see in the fiddle , the image actually only starts to shrink when the window gets really small, almost less then the mobile version
HTML:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse" type="button"><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="logo"><img class="img-responsive" src="https://www.martialartsschoolsdirectory.com/logos/profile/checkmat-logo-burbank-ca-184.png"></div>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>NAVBARA</li>
<li>NAVBARA</li>
<li>NAVBARA</li>
<li>d</li>
<li class="dropdown">
NAVBARA
<ul class="dropdown-menu">
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
</ul>
</li>
<li>9</li>
<li>11</li>
<li>12</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
CSS:
.navbar-nav>li>a {
line-height: 6px;
}
.navbar-nav {
float: right;
margin-top: -15px;
}
.navbar {
padding-top: 53px;
font-size: 13px;
text-transform: uppercase;
}
.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;
height: 87px;
}
.navbar-default .navbar-nav>li>a {
color: #ffffff;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
background-color: #F8BD23;
text-decoration: none;
color: #ffffff;
-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-nav > li{
padding-left:30px;
}
body {
background-color: black;
}
.logo img {width:100px;}
otherwise try
add width="100" inside the img tag
To make it shrink you have to make it inline-block and maybe use the following on the img tag:
style="display: inline-block; height: 40px; margin-top: 40px"
You can set whatever height and width you want

Bootstrap navbar-collapsed not keeping background after shrinking

.normal {
height: 75px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.normal .navbar-right {
padding-top: 12px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
#media (max-width: 767px) {
.navbar{height: auto;}
.navbar-brand{
height: auto;}
}
.navbar-collapse{
border: 0px;
}
.navbar-brand {
padding: 0px !important;
}
.navbar-brand img {
max-height: 75px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.shrink {
height: 50px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.shrink .navbar-right {
padding-top: 0px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.shrink .navbar-brand img {
max-height: 50px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
body {
min-height: 2000px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top normal" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed button-middle" 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" href="#"><img src="http://placehold.it/150x70" /></a>
</div>
<div class="navbar-collapse collapse">
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Default</li>
<li>Static top</li>
<li>Fixed top</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
With the .navbar{height: auto;} I fixed the background issue of losing background of navbar-collapsed before scrolling.
The problem is fixing the navbar-collapsed background issue after scrolling when the navbar is shrinked because is interfering with the content after the navbar...
fixed height: 50px; needs to be deleted from the css .shrink class

bootstrap 3 mobile collapse fade in and out on toggle

0Is there anyway of replacing the slide down animation on the mobile navbar-collapse to fade in/out when called upon? I've tried using CSS keyframes and have managed to get the animation working but in reverse - instead of the the menu fading in and out when called upon, the menu is open when the page loads and fades out when the toggle button is pressed.
This is the nav html:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="center">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar- collapse">
<i class="fa fa-bars fa-2x"></i>
</button>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Dierentuin</li>
<li>B-Roll</li>
<li>Carousel</li>
<li>Structural Curtains</li>
<li>Proxy</li>
<li>Art in the Underbelly</li>
<li>Suburbanism</li>
<li>Novelty</li>
<li>Album Covers</li>
<li>Fortyounce London</li>
<li>Covmns Clothing</li>
<li>Siobahn Palmer</li>
<li>Django Django</li>
<li>I like Trains</li>
<li>Glass Animals</li>
<li>Spring Offensive</li>
<li>Black Bird</li>
<li>Olympians</li>
<li>The Soft</li>
<li>Wordplay Issue #10</li>
</ul>
</div>
</nav>
The CSS is as follows:
.navbar-nav {
margin: 0;
min-height: auto;
}
.navbar-nav {
float: none!important;
}
.navbar-nav>li {
float: none;
}
.navbar-inverse {
background-color: transparent;
border-color: transparent;
}
.navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus {
background-color: transparent;
}
.navbar-inverse .navbar-toggle {
border-color: transparent;
}
.nav>li{
display:inline-block;
}
.collapsing {
opacity: 0;
transition:opacity 0.3s linear;
-webkit-transition:opacity 0.3s linear;
-moz-transition:opacity 0.3s linear;
-o-transition:opacity 0.3s linear;
}
.navbar-collapse.collapse.in{
opacity:0;
transition:opacity 0.3s linear;
-webkit-transition:opacity 0.3s linear;
-moz-transition:opacity 0.3s linear;
-o-transition:opacity 0.3s linear;
}
.navbar-collapse.collapse{
opacity: 1;
transition:opacity 0.3s linear;
-webkit-transition:opacity 0.3s linear;
-moz-transition:opacity 0.3s linear;
-o-transition:opacity 0.3s linear;
}
.navbar-collapse {
width: auto;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
margin-top: 194px;
max-height: none;
font-family:"aktiv-grotesk-std";
font-weight: 400;
line-height: 54px;
font-size: 60px;
display:block !important;
}
I'm still learning how to get to grips with Bootstrap 3, so any help would be gratefully received.
Since the collapse plugin modifies the height of the collapsable container you could override the height property using !important:
.navbar-collapse {
opacity: 0;
width: auto;
height: auto !important;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
margin-top: 194px;
max-height: none;
font-family:"aktiv-grotesk-std";
font-weight: 400;
line-height: 54px;
font-size: 60px;
display:block !important;
}
I also included an example on jsfiddle: http://jsfiddle.net/VVrPd/
You should also be careful when using !important, it's not a good practice: What are the implications of using "!important" in CSS?
This solution works better for me, and gets rid of setting the height auto and the !important rules:
.navbar-collapse {
transition: height 3s , opacity 0.3s ;
opacity: 0;
}
There is still a 'slide' transition, but the workaround is setting enough delay (in this case 3s) so will be invisible to the user

Bootstrap collapse is hiding all links in a large viewport

I am trying to use the collapse function in Bootstrap after watching some tutorials I tried it out myself and I am left with no links showing on a large viewport.
Here is my code does anbody notice anything that might be wrong with it?
The HTML:
<nav class="navbar navbar-default affix-top nav-links" data-spy="affix" data-offset-top="100" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/"><img src="media/img/nav-logo.png" alt="Driven Car Sales Logo" class="img-rounded logo-nav navbar-brand"></a>
</div>
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li>Used Cars
</li>
<li>Get Finance
</li>
<li class="dropdown">About Driven<strong class="caret"></strong>
<ul class="dropdown-menu">
<li>
<a href"#">The Team</a>
</li>
<li>
<a href"#">Our Partners</a>
</li>
</ul> <!--Drop Down End-->
</li>
<li>How To Find Us
</li>
<li>Contact Us
</li>
</ul>
</div>
</div>
</nav>
The custom CSS:
.logo-nav {
height: 2.3em;
width: auto;
}
.brand {
font-size: 2em;
margin: 20px 0 25px;
}
.navbar-brand {
opacity: 0;
color: #ff0066;
-webkit-transition:opacity 0.3s ease-in;
-moz-transition:opacity 0.3s ease-in;
-o-transition:opacity 0.3s ease-in;
transition: opacity 0.3s ease-in;
margin-left: 0px;
}
.navbar {
border-radius: 0px;
border-left: none;
border-right: none;
}
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar- default .navbar-nav>.open>a:focus {
color: #fff;
background-color: #DD3B4D;
}
.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus {
color: #fff;
}
.dropdown-menu {
color: #fff;
background-color: #DD3B4D;
}
.dropdown-menu>li>a {
color: #fff;
}
nav.affix {
top: 0;
width: 100%;
z-index: 1000;
}
nav.affix .navbar-brand {
opacity: 1;
height: 2.3em;
width: auto;
}
.navbar-header {
width: 0px;
-webkit-transition:width .4s ease-in-out;
-moz-transition:width .4s ease-in-out;
-o-transition:width .4s ease-in-out;
transition:width .4s ease-in-out;
margin: 0 1em 0 1em
}
nav.affix .navbar-header {
width: 8em;
-webkit-transition: width .4s ease-in-out;
-moz-transition: width .4s ease-in-out;
-o-transition: width .4s ease-in-out;
transition: width .4s ease-in-out;
margin: 0 1em 0 0;
}
.nav-links {
font: 600 15px/1.5 'Arimo';
}
.navbar-nav > li:last-child{
border-right: 1px solid #475d88;
}
ul.nav a:hover {
color: #fff !important;
background-color: #DD3B4D !important;
-webkit-transition: background-color 0.6s ease;
-moz-transition: background-color 0.6s ease;
-o-transition: background-color 0.6s ease;
transition: background-color 0.6s ease;
}
nav.affix .navbar-brand {
display: inline-block;
}
Sorry for the amount of CSS I didn't realise how much there was ha.
I have had a good play about and can't seem to stop this from happening.
Remove the collapse class
Link http://jsfiddle.net/LvhCh/1/
<div class="nav-collapse navbar-responsive-collapse" data-toggle="collapse" data-target=".navbar-nav">