Center Align Menu in Bootstrap Navbar


The top navigation menu bar can be created easily with Bootstrap. Generally, the menu is aligned to the left or right side of the top navigation bar. Bootstrap provides an easy way to control the menu alignment. To align the text or menu links in Bootstrap navbar, navbar-nav and navbar-left or navbar-right are used.

However, sometimes it requires aligning menu links in the center of the navbar. But Bootstrap doesn’t have any class for center alignment. In this tutorial, we will show how you can change the position of menu or text to center in the Bootstrap navbar.

The Bootstrap libraries need to be included first to create navigation bar with Bootstrap.

<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>


The following HTML creates a navbar with Bootstrap. The menu will be placed in three different positions, left, right, and center. Add the custom defined class named navbar-center to align menu center.

<nav class="navbar navbar-default" role="navigation">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
    <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-left">
            <li><a href="#">Left</a></li>
        <ul class="nav navbar-nav navbar-center">
            <li><a href="#">Center 1</a></li>
            <li><a href="#">Center 2</a></li>
            <li><a href="#">Center 3</a></li>
        <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Right</a></li>

CSS Code

The following CSS code of the navbar-center class will align the menu or text content to the center position in Bootstrap navbar.

.navbar-nav.navbar-center {
    position: absolute;
    left: 50%;
    transform: translatex(-50%);

Our example code aligns the menu in three positions on Bootstrap navbar like the below.


Related Articles

Comments 0