-1

I have created a navigation bar that you can check its codes in https://jsfiddle.net/atgdLafa/

and have 2 questions:

1- Why the id name of <div> container and <ul> must be the same?If i change the id name of main container then arrangement of list change.

2-How can i change the gap between the lists(suppose 'home' and 'music')

       #navcontainer{
      height: 35px;
      width: 1000px;
      background-color: #ffffff;
      padding-right: 0px;
      margin-top: 0px;
      margin-right: auto;
      margin-left: auto;
      margin-bottom: 0px;
      border:1px solid #f2f2f2;
      }
   /*styling navigation bar*/
#navcontainer ul {
height: 35px;
background: #ffffff;
list-style : none;
float: right;
width:990px;
background-color:#ffffff;
font-family: Tahoma;
margin: auto 0;
padding-right:0px;
}

    #navcontainer ul li { 
    display: inline-block;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    overflow:hidden;
    }

    #navcontainer ul li a {
        text-decoration:none;
        float:right;
        text-align:center;
        line-height:35px;
        font:Tahoma;
            }

        #navcontainer ul li a:hover {
        color:#ffffff;
        }

 li.home a {color: #ffffff;background-color: #0a0a5c; font-weight:bold; font:    Tahoma ; font-size: 12px; height:35px; width:80px; }
 li.musicarchive a {color:#ffffff; background-color: #0a0a5c;  font-weight:bold; font-size: 12px; height:35px; width:120px; }
 li.health a {color:#ffffff; background-color: #0a0a5c; font-weight:bold; font-size: 12px; height:35px; width:90px;}
 li.artandculture a {color:#ffffff; background-color: #0a0a5c; font-weight:bold; font-size: 12px; height:35px;width:120px;}
 li.tech a {color: #ffffff; background-color: #0a0a5c ; font-weight:bold; font-size: 12px; height:35px; width:110px;}


 li.home a:hover {background:  #bb0700;}
 li.musicarchive a:hover {background: #dd423b ;}
 li.health a:hover {background: #B3DE83;}
 li.artandculture a:hover {background: #dd423b;}
 li.tech a:hover {background:#646373  ;}
<div id="navcontainer">
    <ul  id="navcontainer"  dir="rtl" >
     <li class="home"><a href="./index.php" >home</a></li>
     <li class="musicarchive"><a href="music/index.php" >music</a></li>
     <li class="health"><a href="health/health.php">health</a></li>
     <li class="artandculture"><a   href="./artandculture/artandculture.php">art</a></li>
     <li class="tech"><a href="./tech/tech.php">tech</a></li>
    </ul>
   </div><!-- end of nav -->
Drew Kennedy
  • 4,118
  • 4
  • 24
  • 34
Kaveh
  • 2,530
  • 7
  • 29
  • 34

1 Answers1

1

Remove the id from the ul - it's not needed with the CSS you have.

Change margin-left for the #navcontainer ul li rule to change the spacing between the tabs:

#navcontainer {
  height: 35px;
  width: 1000px;
  background-color: #ffffff;
  padding-right: 0px;
  margin-top: 0px;
  margin-right: auto;
  margin-left: auto;
  margin-bottom: 0px;
  border: 1px solid #f2f2f2;
}
/*styling navigation bar*/

#navcontainer ul {
  height: 35px;
  background: #ffffff;
  list-style: none;
  float: right;
  width: 990px;
  background-color: #ffffff;
  font-family: Tahoma;
  margin: auto 0;
  padding-right: 0px;
}
#navcontainer ul li {
  display: inline-block;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  overflow: hidden;
  margin-left: 10px; /* Increase space between tabs */
}
#navcontainer ul li a {
  text-decoration: none;
  float: right;
  text-align: center;
  line-height: 35px;
  font: Tahoma;
}
#navcontainer ul li a:hover {
  color: #ffffff;
}
li.home a {
  color: #ffffff;
  background-color: #0a0a5c;
  font-weight: bold;
  font: Tahoma;
  font-size: 12px;
  height: 35px;
  width: 80px;
}
li.musicarchive a {
  color: #ffffff;
  background-color: #0a0a5c;
  font-weight: bold;
  font-size: 12px;
  height: 35px;
  width: 120px;
}
li.health a {
  color: #ffffff;
  background-color: #0a0a5c;
  font-weight: bold;
  font-size: 12px;
  height: 35px;
  width: 90px;
}
li.artandculture a {
  color: #ffffff;
  background-color: #0a0a5c;
  font-weight: bold;
  font-size: 12px;
  height: 35px;
  width: 120px;
}
li.tech a {
  color: #ffffff;
  background-color: #0a0a5c;
  font-weight: bold;
  font-size: 12px;
  height: 35px;
  width: 110px;
}
li.home a:hover {
  background: #bb0700;
}
li.musicarchive a:hover {
  background: #dd423b;
}
li.health a:hover {
  background: #B3DE83;
}
li.artandculture a:hover {
  background: #dd423b;
}
li.tech a:hover {
  background: #646373;
}
<div id="navcontainer">
  <ul dir="rtl">
    <li class="home"><a href="./index.php">home</a>
    </li>
    <li class="musicarchive"><a href="music/index.php">music</a>
    </li>
    <li class="health"><a href="health/health.php">health</a>
    </li>
    <li class="artandculture"><a href="./artandculture/artandculture.php">art</a>
    </li>
    <li class="tech"><a href="./tech/tech.php">tech</a>
    </li>
  </ul>
</div>
<!-- end of nav -->
J. Titus
  • 9,535
  • 1
  • 32
  • 45
  • ,thanks,for spacing your codes work but when we set it margin-right: 0px; it has still a space,we cannot remove space? – Kaveh Aug 17 '16 at 17:03
  • Looks like you'd need to make it `margin-left: -5px` to remove the spacing altogether and not mess up the right side of the `home` tab. – J. Titus Aug 17 '16 at 17:08
  • Thanks for your answer. – Kaveh Aug 17 '16 at 19:14