Centering Navbar Content - html

Can someone help me center the links on my nav bar please. I have been trying for the last 45 minutes.
Every time I use display: flex and justify-content: center it works until the hamburger button appears and is clicked on and then it all floats to the left.
Any help would be massively appreciated.
Thank you
Reece
.navbar {
background-color: #000;
justify-content: center;
height: auto;
font-family: Gill Sans, Verdana;
font-size: 15px;
line-height: 18px;
text-transform: uppercase;
letter-spacing: 2px;
font-weight: bold;
}
nav li:hover {
background-color: #C00;
margin: 0;
}
<nav>
<div class="navbar-container">
<!--NAVBAR CONTAINER START -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" class="navbar-toggle" data-target="#navbar" 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" href="#"></a>
</div>
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav">
<li class="active">
<strong>HOME</strong>
</li>
<li>
<strong>MEET THE BAND</strong>
</li>
<li>
<strong>PHOTOS</strong>
</li>
<li>
<strong>VIDEOS</strong>
</li>
<li>
<strong>GET IN TOUCH</strong>
</li>
</ul>
</div>
</div>
<!-- NAVBAR CONTAINER END -->
</nav>

Check out this pen http://codepen.io/Danstan/pen/ENajRb the links will be at the center
ul.nav.navbar-nav {
display: table;
margin: 0 auto;
float: none !important;
}

.navbar {
background-color: #000;
height: auto;
font-family: Gill Sans, Verdana;
font-size: 15px;
line-height: 18px;
text-transform: uppercase;
letter-spacing: 2px;
font-weight: bold;
text-align:center;
}
.navbar .navbar-header {
display:table;
width:auto;
margin:auto;
}
nav li:hover {
background-color: #C00;
margin: 0;
}

Try this:-
/* Center Nav Bar */
#nav ul {
text-align: center;
}
link:-http://themes.typepad.com/guide/2011/12/navbar-center.html

Related

How do i add a Logo to my bootstrap nav bar aligned vertically and pulled to the left?

Hey guys i have been trying to add my company logo to the bootstrap nav bar, and my logo is saved in Images/Logo.jpg in the same Directory as that of my index.html, But i just cant seem to add a logo to my nav bar, all i can see is my text for logo and no image. Please help me here is my code. Thanks
HTML
</head>
<body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" class="pull-left" href="#myPage">
<img src="Images/Logo.jpg">The Concetto</span>
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>ABOUT</li>
<li>SERVICES</li>
<li>CAREER</li>
<li>CONTACT</li>
</ul>
</div>
</div>
</nav>
CSS
.container1 {
display: flex;
justify-content: center;
}
.navbar {
margin-bottom: 0;
background-color: #f4511e;
z-index: 9999;
border: 0;
font-size: 12px !important;
line-height: 1.42857143 !important;
letter-spacing: 4px;
border-radius: 0;
font-family: Montserrat, sans-serif;
}
.navbar li a, .navbar .navbar-brand {
color: #fff !important;
}
.navbar-nav li a:hover, .navbar-nav li.active a {
color: #f4511e !important;
background-color: #fff !important;
.navbar-default .navbar-toggle {
border-color: transparent;
color: #fff !important;
}

How can i remove the gap between my navbar items and the bottom of the navbar?

<!--NAVBAR-->
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Page 1</li>
<li>Page 2</li>
<li class="navfixborder">Page 3</li>
</ul>
</div>
</div>
</nav>
And my CSS, the css is basic bootstrap and these are the only classes i edited yet.
.navbar-nav {
margin: 0;
text-align: center;
font-size: .9em;
width:100%;
font-weight: bold;
text-transform: uppercase;
font-family: Roboto, 'Open Sans', Arial; }
.navbar-nav > li {
float: none;
display: inline-block;
margin-left: -5px;
border-left: 2px solid #333240;
} .navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
padding-right: 45px;
padding-left: 45px; }
Navbar gap image
How could i remove that gap from the bottom of my navbar?
Add the following to your css:
.navbar {
min-height: 0;
}
Here is the CodePen I set up:
https://codepen.io/CapySloth/pen/LLQNEG
Bootstrap applies .navbar { min-height: 50px; }. Just overwrite that with min-height: 0;
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<style>
.navbar-nav {
margin: 0;
text-align: center;
font-size: .9em;
width: 100%;
font-weight: bold;
text-transform: uppercase;
font-family: Roboto, 'Open Sans', Arial;
}
.navbar-nav > li {
float: none;
display: inline-block;
margin-left: -5px;
border-left: 2px solid #333240;
}
.navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
padding-right: 45px;
padding-left: 45px;
}
.navbar {
min-height: 0;
}
</style>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Page 1</li>
<li>Page 2</li>
<li class="navfixborder">Page 3</li>
</ul>
</div>
</div>
</nav>
Bootstrap sets min-height: 50px for the .navbar class. A solution would be to set the min-height to zero:
.navbar {
min-height: 0;
}
I added the basics, but there doesn't seem to be any issue.
.navbar-nav {
margin: 0;
text-align: center;
font-size: .9em;
width:100%;
font-weight: bold;
text-transform: uppercase;
font-family: Roboto, 'Open Sans', Arial; } .navbar-nav > li {
float: none;
display: inline-block;
margin-left: -5px;
border-left: 2px solid #333240;
} .navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
padding-right: 45px;
padding-left: 45px; }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Page 1</li>
<li>Page 2</li>
<li class="navfixborder">Page 3</li>
</ul>
</div>
</div>
</nav>

Bootstrap navbar - align button vertically

I'm trying to align a button inside a nav but I can't figure out how to do it. I placed a logo with the height of 50px and aligned other nav items vertically with the line-height property of 50 px. Right now it looks like this:
When I add a line height to the button as well, the border gets streched out.
Here is my HTML:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img alt="Dolm IT" src="img/logo.svg" 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>services</li>
<li>showcase</li>
<li>our team</li>
<button type="button" class="btn btn-default navbar-btn">get in touch</button>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
And here's my CSS:
/*nav*/
.navbar {
background-color: transparent;
border: 0;
}
.navbar-default .navbar-nav > li > a {
color: #01787e;
font-family: 'Akrobat-ExtraBold';
font-size: 1rem;
text-transform: uppercase;
letter-spacing: 2px;
margin-right: 50px;
}
.navbar-nav li a {
line-height: 50px;
}
/*buttons*/
.btn-default {
color: #01787e;
font-family: 'Akrobat-ExtraBold';
font-size: 1rem;
text-transform: uppercase;
letter-spacing: 2px;
}
.btn {
border: 2px solid #01787e;
border-radius: 5px;
padding: 7px 30px;
}
}
You can see the issue here. Thank you for your help.
Give your button.navbar-btn class a margin-top of 25px and you are good to go.
button.navbar-btn{
margin-top:25px
}
Check fiddle: https://jsfiddle.net/4ku2jhm4/1/
Try with this. I did not test it, but it would be something like this.
.nuevo{
width:auto;
text-align:center;
line-height:40px;
padding:5px;
background:green;
display:block;
}
<ul class="nav navbar-nav navbar-right">
<li>services</li>
<li>showcase</li>
<li>our team</li>
<li><a class="nuevo">get in touch</a></li>
</ul>
The top property may be the solution you need here.
.top {
top: 50px;
}
.lineheight {
line-height: 50px;
}
ul {
list-style-type: none;
margin: 0;
overflow: hidden;
border: 1px solid;
}
li {
float: left;
padding: 0px 5px;
}
<button class="top">top</button>
<button class="lineheight">lineheight</button>
<br><br>
<ul class="lineheight">
<li>services</li>
<li>showcase</li>
<li>our team</li>
<button type="button" class="top">get in touch</button>
</ul>

How do I make a navbar that is centered be responsive friendly

I have achieved in making my navbar somewhat centered however it doesn't seem to be very resoponsive friendly. Also, when I collapse the menu my hamburger menu doesn't appear. Any tips would be great!
.navbar-header {
height: 90px;
}
.navbar li {
display: inline;
padding-top: 20px;
float: center;
text-align: center;
}
.navbar {
background: #003643;
}
.navbar li a, .navbar .navbar-brand {
color: #ABD7DE !important;
font-size: 20px;
font-family: 'Lobster', cursive;
text-aline: center;
}
.navbar-nav li a:hover, .navbar-nav li.active a {
color: #284047 !important;
background-color: #ABD7DE !important;
}
#logo {
max-height:150px;
border: none;
border-radius: 50%;
margin-top: -5px;
margin-left: 15px;
}
#nav .navbar-header{
max-width: 900px;
margin-left: 322px;
margin-right: auto;
}
.jumbotron {
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/500602/mountain.jpeg);
height: 700px;
repeat: none;
font-family: 'Lobster', cursive;
color: black;
margin-bottom: 0px;
text-shadow: 1px 1px black;
}
.button-primary {
background: #B1DBDF;
padding: 20px;
font-size: 20px;
border: none;
border-radius: 20px;
padding-left: 40px;
padding-right: 40px;
margin-top: 20px;
}
<nav class="navbar navbar-fixed-top">
<div id="nav" class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>Home</li>
<li>About</li>
<a class="navbar-brand" href="#"><img id="logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/500602/Portfolio_pic.jpg" alt="Zachary" /></a>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
<div class="jumbotron text-center">
<div class="container">
<div style="margin-top:180px" class="row">
<h1>Welcome to my Portfolio!</h1>
<h3>I'm so glad you stopped by!</h3>
<button class="button-primary">Let's get started!</button>
</div>
</div>
</div>
.navbar-header {
height: 90px;
}
.navbar li {
display: inline;
padding-top: 20px;
float: center;
text-align: center;
}
.navbar {
background: #003643;
}
.navbar li a, .navbar .navbar-brand {
color: #ABD7DE !important;
font-size: 20px;
font-family: 'Lobster', cursive;
text-aline: center;
}
.navbar-nav li a:hover, .navbar-nav li.active a {
color: #284047 !important;
background-color: #ABD7DE !important;
}
#logo {
max-height:150px;
border: none;
border-radius: 50%;
margin-top: -5px;
margin-left: 15px;
}
#nav .navbar-header{
max-width: 900px;
margin-left: 322px;
margin-right: auto;
}
.jumbotron {
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/500602/mountain.jpeg);
height: 700px;
repeat: none;
font-family: 'Lobster', cursive;
color: black;
margin-bottom: 0px;
text-shadow: 1px 1px black;
}
.button-primary {
background: #B1DBDF;
padding: 20px;
font-size: 20px;
border: none;
border-radius: 20px;
padding-left: 40px;
padding-right: 40px;
margin-top: 20px;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar .navbar-collapse {
text-align: center;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-fixed-top">
<div id="nav" class="container ">
<div class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<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>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>Home</li>
<li>About</li>
<a class="navbar-brand" href="#"><img id="logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/500602/Portfolio_pic.jpg" alt="Zachary" /></a>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
<div class="jumbotron text-center">
<div class="container">
<div style="margin-top:180px" class="row">
<h1>Welcome to my Portfolio!</h1>
<h3>I'm so glad you stopped by!</h3>
<button class="button-primary">Let's get started!</button>
</div>
</div>
</div>

Why is my logo aligning under my links in my navigation bar?

When I try aligning my logo, it is aligning under the rest of the navigation bar, and under the links? Is there anyway to fix this?
I guess is there a way to get the logo inside of the navigation bar, to the left of the links, but inline with them?
body {
background-color: #ece8e5;
padding: 0;
margin: 0;
font-family: 'Monda', sans-serif;
}
.navbar {
height: 80px;
background-color: black;
padding-top: 16px;
}
.navbar a {
font-size: 26px;
padding-left: 30px !important;
padding-right: 30px !important;
}
.nav {
float: right;
}
.aboutHeader {
text-align: center;
}
.aboutHeader h2 {
padding-bottom: 20px;
}
.aboutHeader p {
font-size: 22px;
}
.footer {
height: auto;
width: 100%;
background-color: black;
padding-bottom: 0;
margin-bottom: 0;
}
.footer p {
padding: 0;
margin: 0;
}
.footer li {
display: inline-block;
padding-left: 100px;
}
.logoImage {
height: 250px;
width: 275px;
padding-top: 0;
float: left;
}
<nav class="navbar navbar-inverse navbar-static-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"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img src="assets/images/logo.png" class="logoImage">
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Home</li>
<li>About</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>