Can't get one list item to space correctly on my navbar no matter what I do

Viewed 46

I've done everything in my power to get the right side of my navbar to space out equally; however, no matter what I do the shop link to the furthest right always has extra space making everything slightly off. I put my code in codepen and went through as much of the code as I could to try and find where the extra spacing is coming from, but no cigar.

/* IMPORTS */

@font-face {
    font-family: "Microgramma W05 Bold Extended";
    src: url("Fonts/5098213/0b230448-6101-4794-9ea9-f219c1a8ca3f.woff2") format("woff2"), url("Fonts/5098213/efd98fb1-2129-4b9a-bc42-293757c7b859.woff") format("woff");
  }
  
  body {
    background-color: white;
    background-position: center bottom;
    background-size: cover;
    background-repeat: no-repeat;
    width: 100%;
    min-height: 100vh;
  }
  
  h1 {
    color: rgb(27, 27, 29);
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.4s;
  }
  
  .li {
    font-family: 'Michroma', sans-serif;
  }
  
  .container {
    margin-left: 0%;
    margin-right: 1%;
  }
  
  
  /* Navbar section */
  
  .nav div.main_list ul li{
    width: 120px;
    height: 65px;
    margin: auto 2rem; /* That will define a equal space between the <li> elements */
}

  
  .nav {
    width: 100%;
    height: 65px;
    position: fixed;
    line-height: 65px;
    text-align: right;
    background-color: rgba(0, 0, 0, 0.8);
  }
  
  div.logo {
    width: 120px;
    height: 65px;
    position: absolute;
    text-transform: uppercase;
    font-family: "Microgramma W05 Bold Extended";
  }
  
  div.logo a {
    text-decoration: none;
    color: #fff;
    font-size: 1.8em;
    color: white;
    font-family: "Microgramma W05 Bold Extended";
  }
  
  .nav div.logo a:hover {
    color: #c0c0c0;
  }
  
  div.main_list {
    width: 600px;
    height: 65px;
    float: right;
    font-size: 14px;
    font-family: Michroma;
    src: url(Michroma.ttf), url(san-serif.ttf);
    text-transform: uppercase;
  }
  
  .nav div.main_list ul {
    width: 100%;
    height: 65px;
    display: flex;
    list-style: none;
  }
  
  .nav div.main_list ul li {
    width: 100%;
    height: 65px;
  }
  
  .nav div.main_list ul li a {
    text-decoration: none;
    color: #fff;
    line-height: 65px;
    text-transform: uppercase;
  }
  
  .nav div.main_list ul li a:hover {
    color: #c0c0c0;
  }
  
  .nav div.media_button {
    width: 40px;
    height: 40px;
    background-color: transparent;
    position: absolute;
    right: 15px;
    top: 12px;
    display: none;
  }
  
  .nav div.media_button button.main_media_button {
    width: 100%;
    height: 100%;
    background-color: transparent;
    outline: 0;
    border: none;
    cursor: pointer;
  }
  
  .nav div.media_button button.main_media_button span {
    width: 98%;
    height: 1px;
    display: block;
    background-color: #fff;
    margin-top: 9px;
    margin-bottom: 10px;
  }
  
  .nav div.media_button button.main_media_button:hover span:nth-of-type(1) {
    transform: rotateY(180deg);
    transition: all 0.5s;
    background-color: #c0c0c0;
  }
  
  .nav div.media_button button.main_media_button:hover span:nth-of-type(2) {
    transform: rotateY(180deg);
    transition: all 0.4s;
    background-color: #c0c0c0;
  }
  
  .nav div.media_button button.main_media_button:hover span:nth-of-type(3) {
    transform: rotateY(180deg);
    transition: all 0.3s;
    background-color: #c0c0c0;
  }
  
  .nav div.media_button button.active span:nth-of-type(1) {
    transform: rotate3d(0, 0, 1, 45deg);
    position: absolute;
    margin: 0;
  }
  
  .nav div.media_button button.active span:nth-of-type(2) {
    display: none;
  }
  
  .nav div.media_button button.active span:nth-of-type(3) {
    transform: rotate3d(0, 0, 1, -45deg);
    position: absolute;
    margin: 0;
  }
  
  .nav div.media_button button.active:hover span:nth-of-type(1) {
    transform: rotate3d(0, 0, 1, 20deg);
  }
  
  .nav div.media_button button.active:hover span:nth-of-type(3) {
    transform: rotate3d(0, 0, 1, -20deg);
  }
  
  
  /* Home section */
  
  .home {
    width: 100%;
    height: 100vh;
    background-color: #ddd;
  }
  
  
  /* Media query section */
  
  @media screen and (min-width: 768px) and (max-width: 1024px) {
    .container {
      margin: 0;
    }
  }
  
  @media screen and (max-width:768px) {
    .container {
      margin: 0;
    }
    .nav div.logo {
      margin-left: 15px;
    }
    .nav div.main_list {
      width: 100%;
      margin-top: 65px;
      height: 0px;
      overflow: hidden;
    }
    .nav div.show_list {
      height: 200px;
    }
    .nav div.main_list ul {
      flex-direction: column;
      width: 100%;
      height: 200px;
      top: 80px;
      right: 0;
      left: 0;
    }
    .nav div.main_list ul li {
      width: 100%;
      height: 40px;
      background-color: rgba(0, 0, 0, 0.8);
    }
    .nav div.main_list ul li a {
      text-align: center;
      line-height: 40px;
      width: 100%;
      height: 40px;
      display: table;
    }
    .nav div.media_button {
      display: block;
    }
  }
  
  
  /* Footer */
  
  footer {
    position: absolute;
    text-align: center;
    bottom: 0;
    width: 100%;
    height: 2.5rem;
    font-size: 10px;
    font-family: Michroma;
    src: url(Michroma.ttf), url(san-serif.ttf);
    text-transform: uppercase;
  }
<!DOCTYPE html>
<html>
    <head>
      <title>{DADD}</title>
        <link rel="icon" href="daddicon.png" type="image/png">
        <link rel="stylesheet" href="dadd1.css">
        <link href="https://fonts.googleapis.com/css2?family=Michroma&display=swap" rel="stylesheet">
      <meta charset="UTF-8">
    </head>
    <body>
        <nav class="nav">
            <div class="container">
                <div class="logo" id="navlogo">
                    <a href="#">DADD</a>
                </div>
             <div class="main_list" id="mainListDiv">
                <ul>
                    <li><a href="#">MUSIC</a></li>
                    <li><a href="#">MIXING</a></li>
                    <li><a href="#">CONTACT</a></li>
                    <li><a href="#">SHOP</a></li>                    
                </ul>
            </div>
                <div class="media_button">
                    <button class="main_media_button" id="mediaButton">
                        <span></span>
                        <span></span>
                        <span></span>
                    </button>
                </div>
            </div>
        </nav>
        <div>
            <footer>
                <p>D.R.E.A.M. LLC</p>
            </footer>
        </div>  
        <!--image-->
    </body>
</html>

2 Answers

This is because you have set a fixed width. You can fix this by using flexbox's justify-content: space-around; on your parent element.

  .nav div.main_list ul li {
    /*width: 120px;*/ /* REMOVE LINE */
    height: 65px;
    margin: auto 2rem;
  }

  .nav div.main_list ul li {
    /*width: 100%;*/ /* REMOVE LINE */
    height: 65px;
  }

  .nav div.main_list ul {
    width: 100%;
    height: 65px;
    display: flex;
    list-style: none;
    justify-content: space-around; /* ADD LINE*/
  }

jsFiddle

U have aligned item to right in .nav and given fixed width of 120px to li , that's why there was inconsistency. Check now:-

.nav {
    width: 100%;
    height: 65px;
    position: fixed;
    line-height: 65px;
    text-align: right;  //Just removed this line
    background-color: rgba(0, 0, 0, 0.8);
  }

/* IMPORTS */

@font-face {
    font-family: "Microgramma W05 Bold Extended";
    src: url("Fonts/5098213/0b230448-6101-4794-9ea9-f219c1a8ca3f.woff2") format("woff2"), url("Fonts/5098213/efd98fb1-2129-4b9a-bc42-293757c7b859.woff") format("woff");
  }
  
  body {
    background-color: white;
    background-position: center bottom;
    background-size: cover;
    background-repeat: no-repeat;
    width: 100%;
    min-height: 100vh;
  }
  
  h1 {
    color: rgb(27, 27, 29);
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.4s;
  }
  
  .li {
    font-family: 'Michroma', sans-serif;
  }
  
  .container {
    margin-left: 0%;
    margin-right: 1%;
  }
  
  
  /* Navbar section */
  
  .nav div.main_list ul li{
    width: 120px;
    height: 65px;
    margin: auto 2rem; /* That will define a equal space between the <li> elements */
}

  
  .nav {
    width: 100%;
    height: 65px;
    position: fixed;
    line-height: 65px;
    background-color: rgba(0, 0, 0, 0.8);
  }
  
  div.logo {
    width: 120px;
    height: 65px;
    position: absolute;
    text-transform: uppercase;
    text-align:right;
    font-family: "Microgramma W05 Bold Extended";
  }
  
  div.logo a {
    text-decoration: none;
    color: #fff;
    font-size: 1.8em;
    color: white;
    font-family: "Microgramma W05 Bold Extended";
  }
  
  .nav div.logo a:hover {
    color: #c0c0c0;
  }
  
  div.main_list {
    width: 600px;
    height: 65px;
    float: right;
    font-size: 14px;
    font-family: Michroma;
    src: url(Michroma.ttf), url(san-serif.ttf);
    text-transform: uppercase;
  }
  
  .nav div.main_list ul {
    width: 100%;
    height: 65px;
    display: flex;
    list-style: none;
  }
  
  .nav div.main_list ul li {
    width: 100%;
    height: 65px;
  }
  
  .nav div.main_list ul li a {
    text-decoration: none;
    color: #fff;
    line-height: 65px;
    text-transform: uppercase;
  }
  
  .nav div.main_list ul li a:hover {
    color: #c0c0c0;
  }
  
  .nav div.media_button {
    width: 40px;
    height: 40px;
    background-color: transparent;
    position: absolute;
    right: 15px;
    top: 12px;
    display: none;
  }
  
  .nav div.media_button button.main_media_button {
    width: 100%;
    height: 100%;
    background-color: transparent;
    outline: 0;
    border: none;
    cursor: pointer;
  }
  
  .nav div.media_button button.main_media_button span {
    width: 98%;
    height: 1px;
    display: block;
    background-color: #fff;
    margin-top: 9px;
    margin-bottom: 10px;
  }
  
  .nav div.media_button button.main_media_button:hover span:nth-of-type(1) {
    transform: rotateY(180deg);
    transition: all 0.5s;
    background-color: #c0c0c0;
  }
  
  .nav div.media_button button.main_media_button:hover span:nth-of-type(2) {
    transform: rotateY(180deg);
    transition: all 0.4s;
    background-color: #c0c0c0;
  }
  
  .nav div.media_button button.main_media_button:hover span:nth-of-type(3) {
    transform: rotateY(180deg);
    transition: all 0.3s;
    background-color: #c0c0c0;
  }
  
  .nav div.media_button button.active span:nth-of-type(1) {
    transform: rotate3d(0, 0, 1, 45deg);
    position: absolute;
    margin: 0;
  }
  
  .nav div.media_button button.active span:nth-of-type(2) {
    display: none;
  }
  
  .nav div.media_button button.active span:nth-of-type(3) {
    transform: rotate3d(0, 0, 1, -45deg);
    position: absolute;
    margin: 0;
  }
  
  .nav div.media_button button.active:hover span:nth-of-type(1) {
    transform: rotate3d(0, 0, 1, 20deg);
  }
  
  .nav div.media_button button.active:hover span:nth-of-type(3) {
    transform: rotate3d(0, 0, 1, -20deg);
  }
  
  
  /* Home section */
  
  .home {
    width: 100%;
    height: 100vh;
    background-color: #ddd;
  }
  
  
  /* Media query section */
  
  @media screen and (min-width: 768px) and (max-width: 1024px) {
    .container {
      margin: 0;
    }
  }
  
  @media screen and (max-width:768px) {
    .container {
      margin: 0;
    }
    .nav div.logo {
      margin-left: 15px;
    }
    .nav div.main_list {
      width: 100%;
      margin-top: 65px;
      height: 0px;
      overflow: hidden;
    }
    .nav div.show_list {
      height: 200px;
    }
    .nav div.main_list ul {
      flex-direction: column;
      width: 100%;
      height: 200px;
      top: 80px;
      right: 0;
      left: 0;
    }
    .nav div.main_list ul li {
      width: 100%;
      height: 40px;
      background-color: rgba(0, 0, 0, 0.8);
    }
    .nav div.main_list ul li a {
      text-align: center;
      line-height: 40px;
      width: 100%;
      height: 40px;
      display: table;
    }
    .nav div.media_button {
      display: block;
    }
  }
  
  
  /* Footer */
  
  footer {
    position: absolute;
    text-align: center;
    bottom: 0;
    width: 100%;
    height: 2.5rem;
    font-size: 10px;
    font-family: Michroma;
    src: url(Michroma.ttf), url(san-serif.ttf);
    text-transform: uppercase;
  }
<!DOCTYPE html>
<html>
    <head>
      <title>{DADD}</title>
        <link rel="icon" href="daddicon.png" type="image/png">
        <link rel="stylesheet" href="dadd1.css">
        <link href="https://fonts.googleapis.com/css2?family=Michroma&display=swap" rel="stylesheet">
      <meta charset="UTF-8">
    </head>
    <body>
        <nav class="nav">
            <div class="container">
                <div class="logo" id="navlogo">
                    <a href="#">DADD</a>
                </div>
             <div class="main_list" id="mainListDiv">
                <ul>
                    <li><a href="#">MUSIC</a></li>
                    <li><a href="#">MIXING</a></li>
                    <li><a href="#">CONTACT</a></li>
                    <li><a href="#">SHOP</a></li>                    
                </ul>
            </div>
                <div class="media_button">
                    <button class="main_media_button" id="mediaButton">
                        <span></span>
                        <span></span>
                        <span></span>
                    </button>
                </div>
            </div>
        </nav>
        <div>
            <footer>
                <p>D.R.E.A.M. LLC</p>
            </footer>
        </div>  
        <!--image-->
    </body>
</html>

Related