Is it possible to center the navbar vertically and horizontally?
/**
* Logo.
*/
.button-logo {
font-family: 'Monoton', cursive;
font-weight:normal;
font-size:40px;
font-weight: 300;
line-height: 40px;
letter-spacing: 1px;
}
.button-logo:hover {
text-decoration: none;
}
.button-logo span {
display: block;
clear:both;
color: #000;
}
/**
* Centerise the logo.
*/
.navbar-header {
float: left;
text-align: center;
width: 100%;
}
.navbar-brand {
float:none;
}
/**
* Centerise the navbar.
*/
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar .navbar-collapse {
text-align: center;
}
/**
* Remove default background, radius, etc.
*/
.navbar {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
border: 0;
background: none;
box-shadow: none;
margin-bottom: 0;
}
.navbar-default .navbar-nav > li > a {
font-family: 'Monoton', cursive;
font-size: 25px;
letter-spacing: 2px;
color: #000;
color: rgba(0, 0, 0, 0.5);
padding-bottom: 0 !important;
}
.navbar-default .navbar-nav > li > a:hover {
color: #000;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
background: none;
background: none;
box-shadow: none;
color: #000;
}
<!-- Static navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="offcanvas" data-target=".navmenu" data-canvas="body">
<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 button-logo" href="#">
<span>brand</span>
<span>brand</span>
<span>brand</span>
</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<!-- menu-box -->
<div class="menu-box">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
<!-- menu-box -->
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</nav>
But this only centers the navbar horizontally not vertically.
Any ideas?
jsfiddle
to place your navbar in the center of your screen you can simply add
nav {
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
https://jsfiddle.net/anpvtaxu/1/
If Igot your question correctly :
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar .navbar-collapse {
text-align: center;
}
<div class="container">
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-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>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</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>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</div>
[UPDATE]
Above is for horizontal center;If you want it to be centered vertically use:
top:50%;
in every element you want it be centered vertically.
Related
I added an image to the navbar-brand and scaled to some point and the problem that i am having is that the links on the right get shifted down. Below the brand div. Help me with this please.
Work and About links are shifted down. Image is attached to this link.
My code is shown below:
<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 text-center" href="#"><img src="img/logo.png" class="img-responsive" width="20%" height="100%"></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="active">Work <span class="sr-only">(current)</span></li>
<li>About</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
CSS for the same is:
.navbar-default {
height: 80px;
border-radius: 0;
border: 0;
border-bottom: 1px solid lightgray;
background: white;
}
.navbar-default .navbar-nav > li > a,
.navbar-brand {
padding-top: 0;
padding-bottom: 0;
line-height: 80px;
margin:0;
}
.navbar-form {
margin-top: 22px;
}
#media (max-width:768px) {
.navbar-default {
height: 50px;
}
.navbar-default .navbar-nav > li > a,.navbar-brand {
padding-top: 0;
padding-bottom: 0;
line-height: 50px;
}
#media (max-width:481px) {
.navbar-default {
height: 50px;
}
.navbar-default .navbar-nav > li > a,.navbar-brand {
padding-top: 0;
padding-bottom: 0;
line-height: 50px;
}
Please help me with the solution to this.
This is an OLD question for Bootstrap 3 -> changing the collapse point for the navbar, but the methodologies suggested here:
https://coderwall.com/p/wpjw4w/change-the-bootstrap-navbar-breakpoint
and here:
Bootstrap 3 Navbar Collapse
do not work for collapsing below 768px, it only seems to work for extending the collapse point, not retracting it. I have a particular situation where my navbar has 3 buttons, so it doesn't need to collapse so early. I would like it to collapse at 420px instead.
Is there a CSS solution to this? If not, can somebody point me towards the correct attribute in the bootstrap customisation page which I need to change and download? Is it the generic breakpoints perhaps? Because there is nothing I can see which says Navbar breakpoints:
http://getbootstrap.com/customize/
As requested, my HTML for the navbar is simply:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<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>
</div>
<div class="navbar-collapse collapse" id = "navbar">
<ul class="nav navbar-nav navbar-left">
<li class = "navbar_buttons"><a id = "new_route_button"><strong>New Route</strong></a></li>
<li class="divider-vertical"></li>
<li class = "navbar_buttons"><a id = "clear_route_button">Clear Route</a></li>
</ul>
<ul class="nav navbar-nav navbar-right"> <!--Right justified navbar list-->
<li class = "navbar_buttons"><a id = "about_button">About</a></li>
</ul>
</div>
</div> <!-- Container -->
</nav> <!-- End of Navbar Container -->
Then I have some CSS to add a vertical division:
/*Preventing vertical dividers from appearing collapsed*/
#media (max-width: 420px) {
.navbar-collapse .nav > .divider-vertical {
display: none;
}
}
/*Defining the vertical dividers*/
.navbar .divider-vertical {
height: 50px;
margin: 0 9px;
border-right: 1px solid #ffffff;
border-left: 1px solid #DADADA;
}
.navbar-inverse .divider-vertical {
border-right-color: #222222;
border-left-color: #111111;
}
Yes, changing the breakpoint to anything less than 768px is different than changing the breakpoint over 768px. You need to override all of the Bootstrap defaults that normally make it collapse.
#media only screen and (min-width: 420px) {
.collapse {
display: block;
}
.navbar-header {
float: left;
}
.navbar-toggle {
display: none;
}
.navbar-nav.navbar-left {
float: left;
margin: 0;
}
.navbar-nav.navbar-right {
float: right;
margin: 0;
}
.navbar-nav>li {
float: left;
}
.navbar-nav>li>a {
padding-top: 15px;
padding-bottom: 15px;
}
}
#media only screen and (max-width: 420px) {
.collapse {
display: none;
}
.navbar-header {
display: block;
}
}
http://www.bootply.com/wpUuFIZqJ2
The following code snippet is based on the original answer, but also works when there are drop down menus in the navbar.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<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>
<style>
#media only screen and (min-width: 560px) {
.collapse {
display: block;
}
.navbar-header {
float: left;
}
.navbar-toggle {
display: none;
}
.navbar>.container .navbar-brand,
.navbar>.container-fluid .navbar-brand {
margin-left: -15px;
}
.container>.navbar-header,
.container-fluid>.navbar-header,
.container>.navbar-collapse,
.container-fluid>.navbar-collapse {
margin-right: 0;
margin-left: 0;
}
.navbar-nav {
float: left;
margin: 0;
}
.navbar-nav.navbar-right {
float: right;
margin: 0;
}
.navbar-nav>li {
float: left;
}
.navbar-nav>li>a {
padding-top: 15px;
padding-bottom: 15px;
}
.navbar-nav .open .dropdown-menu {
position: absolute;
float: left;
width: auto;
margin-top: 2px;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.15);
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
}
.navbar-inverse .navbar-nav .open .dropdown-menu .divider {
background-color: #e5e5e5;
}
.navbar-inverse .navbar-nav .open .dropdown-menu>li>a {
color: #333;
}
.navbar-nav .open .dropdown-menu>li>a {
line-height: 1.42857143;
}
.navbar-nav .open .dropdown-menu>li>a,
.navbar-nav .open .dropdown-menu .dropdown-header {
padding: 3px 20px;
}
.navbar-right .dropdown-menu {
right: 0;
left: auto;
}
}
#media only screen and (max-width: 559px) {
.collapse {
display: none;
}
.navbar-header {
display: block;
}
}
</style>
<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="#">Brand</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 class="active">Link <span class="sr-only">(current)</span></li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
<li role="separator" class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
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>
I want my navbar to span the entire width like this www.ramenchicago.com but right now i can only get it all on the right.
I have my css set up like this
.navbar-wrapper > .container {
padding-right: 0;
padding-left: 0;
width: 100%;
}
.navbar-wrapper .navbar {
padding-right: 15px;
padding-left: 15px;
width: 100%;
background-color: rgba(0,0,0,0.8);
}
li {
border-left: solid 1px white;
}
li:hover {
background: rgba(0,0,0,0.3);
}
#navbar {
display: table-row;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="navbar-wrapper">
<div class="container">
<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>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">HOME</li>
<li class="dropdown">
ABOUT<span class="caret"></span>
<ul class="dropdown-menu">
<li>LOCATION</li>
<li>PRESS</li>
</ul>
</li>
<li>STRINGS 1</li>
<li>STRINGS 2</li>
<li>HELL RAMEN</li>
<li>JOBS</li>
<li>DARK CHEFS</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
Should I change my ul or li? Please help me out!
Also, it's my first time using Bootstrap so I'm not familiar with it yet. How do I remove the little arrow on the dropdown menu?
Thanks!
Set ul width to 100%
.navbar-nav {
float: left;
margin: 0;
width: 100%;
}
and it's li as 100% divide by number of li it has. You have 7 li, So it will be width: 14%; like this
.navbar-nav>li {
float: left;
text-align: center;
width: 14%; /* 100 divide by 7 li = 14 */
}
For the arrow on dropdown, Just remove <span class="caret"></span> there.
.navbar-wrapper > .container {
padding-right: 0;
padding-left: 0;
width: 100%;
}
.navbar-wrapper .navbar {
padding-right: 15px;
padding-left: 15px;
width: 100%;
background-color: rgba(0,0,0,0.8);
}
.navbar-nav {
float: left;
margin: 0;
width: 100%;
}
.navbar-nav>li {
float: left;
text-align: center;
width: 14%; /* 100 divide by 7 li = 14 */
}
li {
border-left: solid 1px white;
}
li:first-child{
border: 0;
}
li:hover {
background: rgba(0,0,0,0.3);
}
#navbar {
display: table-row;
}
<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.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="navbar-wrapper">
<div class="container">
<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>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">HOME</li>
<li class="dropdown">
ABOUT
<ul class="dropdown-menu">
<li>LOCATION</li>
<li>PRESS</li>
</ul>
</li>
<li>STRINGS 1</li>
<li>STRINGS 2</li>
<li>HELL RAMEN</li>
<li>JOBS</li>
<li>DARK CHEFS</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
You shouldn't need to nest containers and if you change your display properties to a table format you should see the results you're looking for.
.navbar-nav {
display: table;
width: 100%;
}
.navbar-nav > li {
display: table-cell;
float: none;
}
.navbar-nav > li > a {
text-align: center;
}
*Note: I would place these inside a media query so it doesn't disturb your mobile navigation.
See working examples.
Full width of the browser
#media (min-width: 768px) {
.navbar-wrapper .container-fluid {
padding-right: 0;
padding-left: 0;
width: 100%;
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav {
display: table;
width: 100%;
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li {
display: table-cell;
float: none;
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li > a {
text-align: center;
}
}
.navbar-wrapper .navbar {
background-color: rgba(0, 0, 0, 0.8);
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li {
border-left: solid 1px white;
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li:hover {
background: rgba(0, 0, 0, 0.3);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar-wrapper">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" 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>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">HOME
</li>
<li class="dropdown">
ABOUT<span class="caret"></span>
<ul class="dropdown-menu">
<li>LOCATION
</li>
<li>PRESS
</li>
</ul>
</li>
<li>STRINGS 1
</li>
<li>STRINGS 2
</li>
<li>HELL RAMEN
</li>
<li>JOBS
</li>
<li>DARK CHEFS
</li>
</ul>
</div>
</div>
</nav>
</div>
Alternative: Full width of a container
#media (min-width: 768px) {
.navbar-wrapper .navbar.navbar-inverse .navbar-nav {
display: table;
width: 100%;
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li {
display: table-cell;
float: none;
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li > a {
text-align: center;
}
}
.navbar-wrapper .navbar {
background-color: rgba(0, 0, 0, 0.8);
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li {
border-left: solid 1px white;
}
.navbar-wrapper .navbar.navbar-inverse .navbar-nav > li:hover {
background: rgba(0, 0, 0, 0.3);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar-wrapper">
<div class="container">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" 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>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">HOME
</li>
<li class="dropdown">
ABOUT<span class="caret"></span>
<ul class="dropdown-menu">
<li>LOCATION
</li>
<li>PRESS
</li>
</ul>
</li>
<li>STRINGS 1
</li>
<li>STRINGS 2
</li>
<li>HELL RAMEN
</li>
<li>JOBS
</li>
<li>DARK CHEFS
</li>
</ul>
</div>
</nav>
</div>
</div>
I have a fixed-top navigation bar with content inside that needs to be center aligned vertically. Additionally, I'm using bootstrap to me design my page. The navigation bar has two major content blocks. One is an image as my nav header and one has a container of an with links.
The container I wrapped around the two does not have any vertical padding and only has margins for content going underneath it.
<!--Navigation Bar-->
<nav class="navbar navbar-default navbar-fixed-top navbar-wrap">
<div class="container-fluid">
<div class="navbar-header">
<img src="img/logo.png" />
</div>
<ul class="nav navbar-nav navbar-right">
<li>Who Am I?</li>
<li>Projects</li>
<li>Contact</li>
</ul>
</div>
</nav>
What I have tried doing is set the .container-fluid>ul to be relative to the container and set the margin to auto. I do not want to have a fixed margin or padding for it since I want the site to scale well even on mobile devices (hence why I'm using bootstrap).
I am a very amateur developer and just trying to get a site off the ground so I can showcase my projects from school and side gigs.
Thanks in advanced, if you would like to see my CSS. I can edit it in too.
http://imgur.com/pXcwav3
.navbar-wrap {
padding: 0;
background-color: #77B69C;
}
.nav {
padding-right: 15px;
}
.navbar-right {
margin-right: 0;
}
.container-fluid>ul {
position: relative;
height: 100%;
margin: auto;
}
.navbar-default .navbar-nav>li>a {
color: #ECF0F1;
border-radius: 5px;
transition: background-color 0.5s;
}
.navbar-default .navbar-nav>li>a:hover {
color: #171F26;
background-color: #fff;
}
There are multiple ways you can handle this depending on what makes most sense.
1) You could actually use text and adjust it with CSS like in the first
navbar example.
2) You can constrain the image to the navbars default height like in
example 2.
3) And you can adjust the height and line height like in example 3 for an
image that exceeds the height of the navbar.
** Also, if you are using a preprocessor (LESS or SASS) you can easily adjust the height and the rest is handled.
I also inserted the HTML so your navbar collapses (Navbar Docs)under 768px into the mobile configuration (unsure if the omission was meant or not).
(if you do use the 2nd or 3rd option just remove the margin-top class from navbar-wrap* so the nav is fixed to the top again.)
#import url(https://fonts.googleapis.com/css?family=Hind+Vadodara);
/**Text CSS**/
.navbar.navbar-wrap {
background: #77B69C;
}
.navbar a.navbar-brand,
.navbar a.navbar-brand:hover,
.navbar a.navbar-brand:focus {
font-family: 'Hind Vadodara', sans-serif;
font-size: 30px;
color: #000;
letter-spacing: 5px;
}
.navbar .navbar-brand span.lname {
color: #fff;
}
.navbar.navbar-wrap .navbar-nav > li > a {
font-family: 'Hind Vadodara', sans-serif;
color: #ECF0F1;
border-radius: 5px;
transition: background-color 0.5s;
}
.navbar.navbar-wrap .navbar-nav > li > a:hover {
color: #171F26;
background-color: #fff;
}
#media (min-width: 768px) {
.navbar.navbar-wrap .navbar-right {
margin-right: 15px;
}
.navbar.navbar-wrap .navbar-brand {
margin-left: 15px;
}
}
/**IMG CSS**/
.navbar.navbar-wrap2 .navbar-brand {
padding: 0;
margin: 0;
}
.navbar.navbar-wrap2 .navbar-brand img {
height: 50px;
width: 300px;
padding: 0;
margin: 0;
left: 0;
}
.navbar.navbar-wrap2 {
background: #77B69C;
margin-top: 200px;
}
.navbar.navbar-wrap2 .navbar-nav > li > a {
font-family: 'Hind Vadodara', sans-serif;
color: #ECF0F1;
border-radius: 5px;
transition: background-color 0.5s;
}
.navbar.navbar-wrap2 .navbar-nav > li > a:hover {
color: #171F26;
background-color: #fff;
}
.navbar.navbar-wrap2 .navbar-brand img {
margin-left: 15px;
}
#media (min-width: 768px) {
.navbar.navbar-wrap2 .navbar-right {
margin-right: 15px;
}
}
/**LARGE IMG CSS**/
.navbar.navbar-wrap3 .navbar-brand {
padding: 0;
margin: 0;
}
.navbar.navbar-wrap3 .navbar-brand img {
height: 75px;
width: 300px;
padding: 0;
margin: 0;
left: 0;
}
.navbar.navbar-wrap3 {
background: #77B69C;
margin-top: 400px;
}
.navbar.navbar-wrap3 .navbar-header {
height: 75px;
}
.navbar.navbar-wrap3 .navbar-toggle {
margin-top: 20px;
}
.navbar.navbar-wrap3 .navbar-nav > li > a {
font-family: 'Hind Vadodara', sans-serif;
color: #ECF0F1;
border-radius: 5px;
transition: background-color 0.5s;
}
.navbar.navbar-wrap3 .navbar-nav > li > a:hover {
color: #171F26;
background-color: #fff;
}
.navbar.navbar-wrap3 .navbar-brand img {
margin-left: 15px;
}
#media (min-width: 768px) {
.navbar.navbar-wrap3 .navbar-right {
margin-right: 15px;
}
.navbar.navbar-wrap3 .navbar-nav > li > a {
line-height: 45px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-wrap 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-nav" 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="#"><span class="fname">James</span> <span class="lname">Wong</span></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-nav">
<ul class="nav navbar-nav navbar-right">
<li>Who Am I?
</li>
<li>Projects
</li>
<li>Contact
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<hr>
<nav class="navbar navbar-default navbar-wrap2 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-nav2" 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://academe.co.uk/wp-content/uploads/2014/10/sugarcrmLogoWhiteBackground_RGB.png" />
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-nav2">
<ul class="nav navbar-nav navbar-right">
<li>Who Am I?
</li>
<li>Projects
</li>
<li>Contact
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<hr>
<nav class="navbar navbar-default navbar-wrap3 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-nav3" 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://academe.co.uk/wp-content/uploads/2014/10/sugarcrmLogoWhiteBackground_RGB.png" />
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-nav3">
<ul class="nav navbar-nav navbar-right">
<li>Who Am I?
</li>
<li>Projects
</li>
<li>Contact
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>