how to navbar centering code example

Example 1: css menu center of screen

/* css code */
.container{            
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  position: absolute;
}

/* html code */
<div class="container">
    <li><a href="#" class="link">Home</a></li>
    <li><a href="#" class="link">About Us</a></li>
    <li><a href="#" class="link">Services</a></li>
    <li><a href="#" class="link">Gallery</a></li>
    <li><a href="#" class="link">Contact</a></li>
</div>

Example 2: menu always center css

#nav ul {
    display: inline-block;
    list-style-type: none;
}

Tags:

Html Example