Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I center my Navbar?

Tags:

html

css

bulma

I looked on here before, but nothing really worked. I am using Bulma Framework which I believe is relatively unheard of, yet I was hoping you could help me center the brand link on the navbar. This is what I have it at right now:

.navbar {
  background-color: #0a0a0a;
  color: white;
  height: 9%;
}

.navbar .navbar-brand > .navbar-item,
.navbar .navbar-brand .navbar-link {
  color: white;
  font-family: 'Wavehaus';
}

I have a link on Codepen so that it can be visualized:

https://codepen.io/anon/pen/BwrWwg

Note that the font will not show up.

like image 520
Andrew Chon Avatar asked Oct 08 '17 19:10

Andrew Chon


People also ask

How do I center my navigation bar vertically?

The key is to place the logo image in the first <li> element of your list. You then display all the elements of the list as inline and use vertical-align: middle to line them up. You can adjust the padding and margin properties to get the exact look that you need.

How do I center align my screen?

You can do this by setting the display property to "flex." Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.

How do I center a horizontal navigation bar in CSS?

Suppose you have four items in your navigation menu–you can work out the width of these and use margin:0 auto; to centre them. Adding a fifth will increase the width, meaning you'd need to alter the CSS, too.


1 Answers

You just need to set the right display for the navbar. Currently, Bulma makes use of Flex Layout. Now clearing the flex and making it use block will make it work:

.navbar .navbar-brand {
  text-align: center;
  display: block;
  width: 100%;
}

.navbar .navbar-brand > .navbar-item,
.navbar .navbar-brand .navbar-link {
  display: inline-block;
}
like image 122
Praveen Kumar Purushothaman Avatar answered Sep 19 '22 09:09

Praveen Kumar Purushothaman