0

By default bulma css framework left aligns all items in the navbar. However that's very inconvenient for big displays.

Having this html layout (as per bulma's documentation):

<head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
</head>

<body>
  <div class="navigation">
    <nav class="navbar" role="navigation" aria-label="main navigation">
      <div class="navbar-brand">
        <a class="navbar-item" href="http://localhost:8000">
          <img src="https://bulma.io/images/bulma-logo.png" width="50">
        </a>
        <a class="navbar-item" href="http://localhost:8000">Sitename</a>
        <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navMenu">
          <span aria-hidden="true"></span>
          <span aria-hidden="true"></span>
          <span aria-hidden="true"></span>
        </a>
      </div>
      <div class="navbar-menu" id="navMenu">
        <div class="navbar-start">
          <a class="navbar-item" href="/link1.html">link 1</a>
          <a class="navbar-item" href="/link2.html">link 2</a>
          <a class="navbar-item" href="/link3.html">link 3</a>
          <a class="navbar-item" href="/link4.hmlt">link 4</a>
        </div>
      </div>
    </nav>
  </div>
</body>

Produces:

enter image description here

Expected output:

enter image description here

Adding additional css:

.navbar {
  align-content: center;
  justify-content: center;
}

Doesn't seem to be enough.

Jsfiddle link: https://jsfiddle.net/q6j9Lyf2/1/

Granitosaurus
  • 20,530
  • 5
  • 57
  • 82

2 Answers2

2

Your style written in .navbar class won't apply until unless you add display: flex

.navbar {
  display: flex
  align-content: center;
  justify-content: center;
}

also you have to add

.navbar-menu {
    flex-grow: initial!important;
    flex-shrink: initial!important;
}

Don't like using !important write like this

.navbar .navbar-menu {
    flex-grow: initial;
    flex-shrink: initial;
}
moshfiqrony
  • 4,303
  • 2
  • 20
  • 29
0

have you tried this:

.navbar{
    display:flex;
    align-items:center;
}
Ctac
  • 99
  • 1
  • 2
  • 8