im making new website based on bootstrap but everytime i click the button when navbar-collapsed it breaks down, also i would like to get the line where it is supposed to be (at the bottom of navbar) and collapse button in the middle of logo but i couldnt figure it out
HTML
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Zobrazit navigaci</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><img src="logo.png" width="50px" height="50px"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
Škola <b class="caret"></b>
<ul class="dropdown-menu">
<li>
Výroční zprávy
</li>
<li>
Zaměstnanci
</li>
<li>
Historie
</li>
<li>
Kompletní informace
</li>
</ul>
</li>
<li class="dropdown">
Studium <b class="caret"></b>
<ul class="dropdown-menu">
<li>
Informační technologie
</li>
<li>
Agropodnikání
</li>
<li>
Obchodní akademie
</li>
<li>
Maturity
</li>
<li>
Formuláře
</li>
<li>
Třídy
</li>
</ul>
</li>
<li class="dropdown">
Jídelna <b class="caret"></b>
<ul class="dropdown-menu">
<li>
Jídelníček
</li>
<li>
Přihlašování obědů
</li>
</ul>
</li>
<li>
Domov mládeže
</li>
<li>
Galerie
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
CSS
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,700);
html,
body {
height: 100%;
font-family: 'Open Sans', sans-serif;
}
.navbar-fixed-top {
background-color: #5b5147;
border-color: transparent;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
height: 100px;
text-transform: uppercase;
}
.navbar-inverse li {
padding-top: 20px;
}
.navbar-brand {
padding-top: 20px;
}
body {
padding-top: 100px; /* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */
}
.img-portfolio {
margin-bottom: 30px;
}
.img-hover:hover {
opacity: 0.8;
}
/* Home Page Carousel */
header.carousel {
height: 500px;
}
header.carousel .item,
header.carousel .item.active,
header.carousel .carousel-inner {
height: 100%;
}
header.carousel .fill {
width: 100%;
height: 100%;
background-position: center;
background-size: cover;
}
.center-block {
float:none;
display: inline-block;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
text-align: center;
}
#ikonky{
color: #5c6465;
}
/* Footer Styles */
footer {
margin: 50px 0;
}
/* Responsive Styles */
#media(max-width:767px) {
.img-portfolio {
margin-bottom: 15px;
}
header.carousel .carousel {
height: 70%;
}
}
If you change this
.navbar-fixed-top {
height: 100px;
}
to this:
.navbar-fixed-top {
min-height: 100px;
}
The background color should show through on the menu when it's open.
Related
I have created a navigation bar with a hover background color when you hover the mouse over a navigation item.
The problem is when you hover the mouse over the navigation item eg. home, the navigation bar increases in height.
HTML
<nav class="nav" id="home">
<a href="#" class="toggle-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</a>
<div class="navbar-links">
<ul class="nav-list">
<li class="nav-item">home</li>
<li class="nav-item">about me</li>
<li class="nav-item">services</li>
<!-- <li class="nav-item">portfolio</li> -->
<!-- <li class="nav-item">blog</li> -->
<li class="nav-item">contact</li>
<!-- <li class="nav-item">Work</li> -->
</ul>
</div>
</nav>
CSS
.nav {
display: flex;
justify-content: right;
align-items: center;
background-color: var(--clr-main);
}
.nav-item {
margin-right: 10px;
list-style: none;
}
.nav-link{
font-size: 20px;
text-decoration: none;
color: var(--clr-secondary);
font-weight: var(--fw-bold);
display: block;
}
.nav-list{
display: flex;
padding: 0;
}
.nav-item:hover{
background-color: #00a6ff;
padding: 10px;
}
Is there a way to hover over the navigation item and not increase the size of the navigation bar? The increase in size makes the padding background color not reach the top and bottom of the navigation bar.
You'll need to add padding to the nav-item class in CSS:
.nav {
display: flex;
justify-content: right;
align-items: center;
background-color: var(--clr-main);
}
.nav-item {
margin-right: 10px;
padding: 10px;
list-style: none;
}
.nav-link{
font-size: 20px;
text-decoration: none;
color: var(--clr-secondary);
font-weight: var(--fw-bold);
display: block;
}
.nav-list{
display: flex;
}
.nav-item:hover{
background-color: #00a6ff;
}
<nav class="nav" id="home">
<a href="#" class="toggle-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</a>
<div class="navbar-links">
<ul class="nav-list">
<li class="nav-item">home</li>
<li class="nav-item">about me</li>
<li class="nav-item">services</li>
<!-- <li class="nav-item">portfolio</li> -->
<!-- <li class="nav-item">blog</li> -->
<li class="nav-item">contact</li>
<!-- <li class="nav-item">Work</li> -->
</ul>
</div>
</nav>
Q1
How can I make my navigation bar static?
Q2
How can I move up the background picture to ensure there is no white gaps and adjust the height of the background image? I think I have to use padding to move up the image and use height to manipulate the height of the background image. Is that correct?
Q3
How can delete the white gap above my footer text at the bottom of the webpage section 3 contact us?
HTML code
<!DOCTYPE html>
<html>
<head>
<html lang="en">
<meta charset="UTF-8">
<title>Liam Docherty | London Web Developer & GFX designer</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="http://placehold.it/60x60" alt="Your Brand Name"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home
</li>
<li class="dropdown">
About Me <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li class="dropdown">
Units <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li>Clients
</li>
<li>Contact Me
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<section class="section1">
<div class="hero"></div>
<i class="fa fa-angle-down" style="font-size:100px;"></i>
</section>
<section class="section2" id = "section2">
<i class="fa fa-angle-down" style="font-size:100px;"></i>
</section>
<section id="contact-me" class="contact_section">
</section>
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
<footer>
<div class="page">
<h1 class="footer">Copyright © 2017 Liam Docherty's Site. All rights reserved.</h1>
</div>
</footer>
</html>
CSS
<style>
body {
margin: 0;
padding: 0;
}
.navbar.navbar-default {
background-color: #4D5061;
height: 10vh;
z-index: 100;
}
.navbar.navbar-default ul {
list-style-type: none;
text-align: center;
}
.navbar.navbar-default ul li {
display: inline-block;
}
.dropdown .dropdown-menu {
background-color: #4D5061;
}
.dropdown .dropdown-menu a {
color: white;
}
.navbar.navbar-default ul li a {
display: inline-block;
padding: 3.5vh 8px 4px;
color: white;
text-decoration: none;
font-size: 14pt;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul li:after {
content: '';
position: absolute;
right: 50%;
bottom: 0;
left: 50%;
height: 3px;
background-color: red;
border-radius: 9px;
transition: all .2s;
}
.navbar.navbar-default ul li a:hover {
color: red;
}
.nav.navbar-nav,
.nav.navbar-nav>li {
float: none;
}
.navbar.navbar-default ul li:hover:after {
right: 0;
left: 0;
}
a:hover {
color: red;
text-decoration: none;
}
#logo {
padding-top: 2vh;
padding-left: 20px;
float: left;
}
section {
position: relative;
}
.section1 {
height: 90vh;
text-align: center;
color: white;
background-image: url("https://static.pexels.com/photos/48727/pexels-photo-48727.jpeg");
background-attachment: fixed;
}
.section2 {
height: 95vh;
background-color: #A59E8C;
text-align: center;
color: white;
}
.contact_section {
height: 93vh;
background-color: grey;
}
.fa-angle-down {
color: #4D5061;
position: absolute;
bottom: 0px;
}
footer {
height: 5vh;
background-color: #4D5061;
text-align: center;
margin:0;
padding:0;
right:0;
bottom:0;
left:0:
}
h1{
font-size: 14pt;
color: white;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul.dropdown-menu li,
.navbar.navbar-default ul.dropdown-menu li a {
position: relative;
display: block;
}
</style>
1) Use the navbar-fixed-top class provided by Bootstrap to fix the navbar in place.
2) Change the height property of the section1 class.
3) Create a new section, reduce the height, and remove margin/padding from your h1 class (you had a typo in your CSS, .footer not footer).
Result:
https://jsfiddle.net/vnkevsnt/8/
You'll need to add position:fixed to your .navbar.navbar-default to fix it. Also be sure to add width:100% to make it full width.
(Have a look at positioning) - Bootstrap probably can position with a class but I'm not sure.
Regarding the white space at the bottom, I would personally remove the height:5vh from the footer and also add margin:0 to the H1 element.
Bootstrap has nav-fixed class
<nav class="navbar navbar-default navbar-fixed-top">
....
</nav>
Sample: https://getbootstrap.com/examples/navbar-fixed-top/
I'm trying to place the picture of mine which is <div class="shape"> on top of the background image which is <div class="hero"> just above the center using bootstrap.
However, the background color and image both appear above my picture. I'm looking for the background image to go behind my picture and for the background color not to be seen at this moment in time.
Please don't delete the background color if you decide to help me as I want to do something with it at a later stage.
Please open the snippet in full screen to see my issue.
<style>
.body {
font-family: 'Roboto', sans-serif;
color: black;
}
.navbar.navbar-default {
background-color: #FFFFFF;
height: 10vh;
z-index: 100;
}
.navbar.navbar-default ul {
list-style-type: none;
text-align: center;
}
.navbar.navbar-default ul li {
display: inline-block;
}
.dropdown-menu li {
text-align: center;
}
.dropdown .dropdown-menu {
background-color: #FFFFFF;
}
.dropdown .dropdown-menu a {
color: white;
}
.navbar.navbar-default ul li a {
display: inline-block;
padding: 3.5vh 8px 4px;
color: black;
text-decoration: none;
font-size: 14pt;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul li:after {
content: '';
position: absolute;
right: 50%;
bottom: 0;
left: 50%;
height: 3px;
background-color: black;
border-radius: 9px;
transition: all .2s;
}
.nav.navbar-nav,
.nav.navbar-nav>li {
float: none;
}
.navbar.navbar-default ul li:hover:after {
right: 0;
left: 0;
}
.navbar.navbar-default ul.dropdown-menu li,
.navbar.navbar-default ul.dropdown-menu li a {
position: relative;
display: block;
}
.section {
min-height: 100vh;
}
.one {
background-color:#c00;
}
.two {
background: #563D7C;
}
#sections .section {
padding-top: ~50px;
}
.hero {
background: url("http://mowebusa.nobletechindia.com/wp-content/uploads/2016/05/computer.jpg") center center no-repeat;
background-attachment: fixed;
position: relative;
background-size: cover;
width: 100%;
max-width: 100%;
width: 100vw;
height: 100%;
}
.shape {
border-radius: 25px;
background: #4D5061;
content: url(http://i1126.photobucket.com/albums/l611/ldocherty1/IMG_0730_zpsiz4dqc47.jpg);
color: white;
height: 300px;
margin: auto;
padding: 3px;
width: 300px;
margin-left: auto;
margin-right: auto;
}
</style>
!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.4/jquery.fullpage.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home
</li>
<li class="dropdown">
About Me <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Contact
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li class="dropdown">
Units <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li>Clients
</li>
<li>Contact Me
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div id="sections">
<div class="section one">
<div class="shape"></div>
<div class="hero"></div>
<i class="fa fa-angle-down" style="font-size:100px;"></i>
</div>
<div class="section two"></div>
<i class="fa fa-angle-up" style="font-size:100px;"></i>
</div>
<script>
$(document).ready(function() {
$('#sections').fullpage();
});
</script>
</body>
</html>
You can do this by following the steps below:
add position: absolute to .shape to overlap the hero image.
add z-index: 10 to get .shape on top of .hero image
Now, to center align a positioned element, keep in mind the following trick:
use left: 50% to put the positioned element 50% from the left.
add margin-left: -150px
The 1st step would have worked just fine if the element had width of 1px (.shape will start after 50% from left) but since it has a width of 300px, you will have to add a negative margin-left equal to half the width of the element (300/2 = 150).
Similarly, for vertical alignment you can use top: 50% and a negative margin-top equal to 1/2 of the height.
Note: There was issue on padding-top: ~50px;, remove the ~ as it is invalid token. Also, padding can't be in negative.
.body {
font-family: 'Roboto', sans-serif;
color: black;
}
.navbar.navbar-default {
background-color: #FFFFFF;
height: 10vh;
z-index: 100;
}
.navbar.navbar-default ul {
list-style-type: none;
text-align: center;
}
.navbar.navbar-default ul li {
display: inline-block;
}
.dropdown-menu li {
text-align: center;
}
.dropdown .dropdown-menu {
background-color: #FFFFFF;
}
.dropdown .dropdown-menu a {
color: white;
}
.navbar.navbar-default ul li a {
display: inline-block;
padding: 3.5vh 8px 4px;
color: black;
text-decoration: none;
font-size: 14pt;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul li:after {
content: '';
position: absolute;
right: 50%;
bottom: 0;
left: 50%;
height: 3px;
background-color: black;
border-radius: 9px;
transition: all .2s;
}
.nav.navbar-nav,
.nav.navbar-nav>li {
float: none;
}
.navbar.navbar-default ul li:hover:after {
right: 0;
left: 0;
}
.navbar.navbar-default ul.dropdown-menu li,
.navbar.navbar-default ul.dropdown-menu li a {
position: relative;
display: block;
}
.section {
min-height: 100vh;
}
.one {
background-color: #c00;
}
.two {
background: #563D7C;
}
#sections .section {
padding-top: 50px;
}
.hero {
background: url("http://mowebusa.nobletechindia.com/wp-content/uploads/2016/05/computer.jpg") center center no-repeat;
background-attachment: fixed;
position: relative;
background-size: cover;
width: 100%;
max-width: 100%;
width: 100vw;
height: 100%;
}
.shape {
border-radius: 25px;
background: #4D5061;
content: url(http://i1126.photobucket.com/albums/l611/ldocherty1/IMG_0730_zpsiz4dqc47.jpg);
color: white;
height: 300px;
margin: auto;
padding: 3px;
width: 300px;
/* add this */
position: absolute;
left: 50%;
margin-left: -150px;
z-index: 10;
}
!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.4/jquery.fullpage.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home
</li>
<li class="dropdown">
About Me <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Contact
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li class="dropdown">
Units <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li>Clients
</li>
<li>Contact Me
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div id="sections">
<div class="section one">
<div class="shape"></div>
<div class="hero"></div>
<i class="fa fa-angle-down" style="font-size:100px;"></i>
</div>
<div class="section two"></div>
<i class="fa fa-angle-up" style="font-size:100px;"></i>
</div>
<script>
$(document).ready(function() {
$('#sections').fullpage();
});
</script>
</body>
</html>
I have made my navbar taller in bootstrap using
.navbar {
padding-top: 15px;
padding-bottom: 15px;
}
However now the background of the active navbar link looks like this
How do I get the pictured grey background to span the full height of the navbar? I tried various things such as increasing the padding, and this does make it taller, but it doesn't actually extend over the purple, which is what I want.
Example here: http://jsfiddle.net/pjxd9cka/
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.navbar {
padding-top: 15px;
padding-bottom: 15px;
border: 0;
border-radius: 0;
margin-bottom: 0;
font-size: 12px;
letter-spacing: 5px;
}
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-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>
Bootstrap 3 Menu Generator
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li>
Getting started
</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
<li>
Components
</li>
<li>
JavaScript
</li>
<li class="active">
Customize
</li>
</ul>
</nav>
</div>
</header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
The active element is what's producing the highlighted color, meaning you need to make the active element larger if you want it to grow.
One solution is to add your additional padding to the a elements inside the menu instead of to the outer menu container. Since bootstrap's default padding is 15px, you'll need to make it 15+15=30px top and bottom. It may also be different padding for different media screen sizes. Once you do this, in order to keep the navbar-header aligned, you'll need to add a margin to the top of that too.
.navbar {
border: 0;
border-radius: 0;
margin-bottom: 0;
font-size: 12px;
letter-spacing: 5px;
background-color: teal;
}
.navbar-header {
margin-top: 15px;
}
.nav li a {
padding-top: 30px;
padding-bottom: 30px;
}
Here's a fiddle illustrating this.
A quick fix would be to add a negative margin to your links.
.navbar a {
margin-top: -15px;
margin-bottom: -15px;
Or perhaps a better method would be to change play with the height of the links.
.navbar a {
height: 100%;
margin-top: 0;
margin-bottom: 0;
I've redefined paddings and margins for three other classes instead of the .navbar class:
.navbar-brand
.navbar-toggle
.navbar-nav > li > a
Please check the result: http://jsfiddle.net/glebkema/hwk7kjmo/
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.navbar {
/*
padding-top: 15px;
padding-bottom: 15px;
*/
border: 0;
border-radius: 0;
margin-bottom: 0;
font-size: 12px;
letter-spacing: 5px;
}
.navbar-brand {
height: 80px; /* 50px by default */
padding-bottom: 30px; /* 15px by default */
padding-top: 30px;
}
.navbar-toggle {
margin-bottom: 20px; /* 8px by default */
margin-top: 20px;
padding-bottom: 12px; /* 9px by default */
padding-top: 12px;
}
#media (min-width: 768px) {
.navbar-nav > li > a {
padding-bottom: 30px; /* 15px by default */
padding-top: 30px;
}
}
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-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>
Bootstrap 3 Menu Generator
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li>
Getting started
</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
<li>
Components
</li>
<li>
JavaScript
</li>
<li class="active">
Customize
</li>
</ul>
</nav>
</div>
</header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
I have a Bootstrap 3 navbar. When I scale the browser window to a low resolution or access the page with my mobile I have no menu. Usually, with Bootstrap I have a collapsed navigation but it is nowhere to be found.
Here is the HTML:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.php"><img src="images/logo.png"></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li class="aktiv" >Advertisers</li>
<li>Publishers</li>
<li>About</li>
<li>Press</li>
</ul>
</div>
</div>
</nav>
CSS:
.navbar {
background-color: #333E48;
border: 0;
display: block!important; /* From Stack Overflow */
}
.navbar-brand > img,
.navbar-brand {
padding:0px;
margin:0;
}
.navbar-brand > img {
padding: 4px;
height: 50px;
margin: auto;
vertical-align: middle;
display: inline-block;
}
.navbar-brand,
.navbar-nav li a {
line-height: 90px;
height: 90px;
padding-top: 0px;
}
.nav-collapse.collapse {
height: auto !important; /* From Stack Overflow */
overflow: visible !important; /* From Stack Overflow */
}
I added display: block!important; to .navbar after reading Nav disappears after resize
I added height: auto !important; overflow: visible !important; to .nav-collapse.collapse after reading Twitter bootstrap responsive navigation disappears after opening and closing
Issue still persists.
It isn't clear in your question but your missing the toggle button to open and close the menu when your viewport is reduced, otherwise the mobile menu will always be open.
nav.navbar-default {
background: #333E48;
border: 0;
}
.navbar-default .navbar-brand > img,
.navbar-default .navbar-brand {
padding: 0px;
margin: 0;
}
.navbar-default .navbar-brand > img {
padding: 4px;
height: 50px;
margin: auto;
vertical-align: middle;
display: inline-block;
}
.navbar-default .navbar-brand,
.navbar-default .navbar-nav li a {
line-height: 90px;
height: 90px;
padding-top: 0px;
}
.navbar-default .nav-collapse.collapse {
height: auto !important;
/* From Stack Overflow */
overflow: visible !important;
/* From Stack Overflow */
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<nav 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="#bs-collapse" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">
<img src="http://placehold.it/100x50/fff/fff" />
</a>
</div>
<div class="collapse navbar-collapse" id="bs-collapse">
<ul class="nav navbar-nav navbar-right">
<li>Home
</li>
<li class="aktiv">Advertisers
</li>
<li>Publishers
</li>
<li>About
</li>
<li>Press
</li>
</ul>
</div>
</div>
</nav>
Just have to remove the collapse class on div#navbar
Here is a fiddle
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.php"><img src="images/logo.png"></a>
</div>
<div id="navbar" class="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li class="aktiv" >Advertisers</li>
<li>Publishers</li>
<li>About</li>
<li>Press</li>
</ul>
</div>
</div>
</nav>
And rewrite the css for the xs view