Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript help with first, last-child

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34208
    cybershot
    Participant

    I am working on a menu and I am having issues with first and last child. my issue is that I am using border-right and border left to put a 1 px border on my list elements and then using first and last child to remove the border for the first link and the last link. It works fine. The problem comes in when I try to position my sub menu where I want it. Because of the code, I found that I need to put the border on the anchor link instead of the list element. I need the list element to have a taller height than the border. So by putting the borders on the anchor tag, I can have it be the size I need and the height of the list element can be the size I need. Problem is that when I add the first and last child to the anchor tag, it does not produce the same results as the li element


    #access .menu-header ul li:last-child {
    border-right: none;
    }

    that works just fine..

    This does not


    #access .menu-header ul a:last-child {
    border-right: none;
    }

    got any experience with this issue?

    #86302
    Johann
    Member

    that’s probably because the anchor tag is the one and only child of each li tag it is embedded in? how about

    #access .menu-header ul li:last-child a {
    border-right: none;
    }

    ?

    #86303
    cybershot
    Participant

    Thank you very much Johann. That worked.

    #86305
    Johann
    Member

    cheers :)

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.