treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Roll over problem on Nav Bar

  • Hi All

    I have a problem with the last rollover image on my navigation bar. It worked OK until I added the "class last" to the unordered list for the right hand seperator image. The anchor link still works but the rollover is only working on the right hand side of the section. I have racked my brain trying to see why this is happening but to no avail.
    I hope one of you good people can look at it and show me where I have gone wrong.
    Thank you in advance for any help.

    Athelstan

    link http://iandelemare.justfree.com/test/
  • From what I can see you need to put the .last on the li tag where it will stay on the a tag and on a:hover. As it is on the a tag and the image is only 30 px wide your a:hover is only affecting that width, not the whole li tag.
  • Thank you VIRTUAL for your time but as i see it, the .last is on the li tag.

    .navBar ul li .last {
    background-image:url(../images/seperator.jpg);
    background-position:right center;
    background-repeat:no-repeat;

    The background hover image is 12px wide by 30px high and repeated in the x axis.

    Athelstan
  • Your class may be on the li in the CSS,
    .navBar ul li .last {
    background-image:url(../images/seperator.jpg);
    background-position:right center;
    background-repeat:no-repeat;

    but it is on the a tag in the html
    <li><a class=\"last\" href=\"#\">Contact Us</a></li>

    So your a:hover state is affecting your <a class="last"> as I said previously.

    However, my previous solution does not work for you as you are using background images for the separators and they cannot be in two positions on the same tag, unless your li tags have a width and the background image for the "last" had the separator on each side. If you were using borders, you could place a left border on all the tags and on the "last tag" have a left and right border.

    This solution will work for you, but it is a bit of a hack
    HTML
    <<div class=\"navBar\"><!--Start navBar-->
    <ul>
    <li><a href=\"#\">Portfolio</a></li>
    <li><a class=\"cyan\" href=\"#\">Design</a></li>
    <li><a class=\"magenta\" href=\"#\">Sign</a></li>
    <li><a class=\"yellow\" href=\"#\">Print</a></li>
    <li><a href=\"#\">Contact Us</a></li>
    <li class=\"last\"><a href=\"#\"></a></li>
    </ul>

    CSS
    .navBar li.last a:hover {
    background-image: none;
    }

    It means you are adding an extra li tag which has no use but to add the separator at the end of the Contact tag and hiding the hover effect by showing background: none.