Page Widget How to - Center Middle Button in nav bar








Question

We would like to know how to center Middle Button in nav bar.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
nav div {<!--from  w  ww.  j  av  a 2  s. c  om-->
  width: 33.3%;
  float: left;
}

#one {
  background: yellow;
}

#two {
  text-align: center;
  background: lime;
}

#three {
  text-align: right;
  background: aqua;
}
</style>
</head>
<body>
  <nav>
    <div id="one">
      <button>One</button>
    </div>
    <div id="two">
      <button>Two</button>
    </div>
    <div id="three">
      <button>Three</button>
    </div>
  </nav>
</body>
</html>

The code above is rendered as follows: