Forums

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

Home Forums CSS [Solved] Another tricky :nth-child question

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30748
    rzea
    Member

    Here you go:

    Let’s say we have a the same nav bar made with one main ul and several li’s and inside those li’s there is a nested ul with its li’s:

















    We then have a first level of li’s and then a second level of li’s.

    How do you select all the li’s from the first level only without having to add a class to each one?

    Here’s the link to the first question: https://css-tricks.com/forums/discussion/9842/tricky-%3Anth-child-question/

    #74364
    noahgelman
    Participant

    Well, if the ul holding everything had an id or class. you could just go:

    ul#id > li

    That’ll target only the the next level elements. You don’t even need to use nth-child.

    #74365
    rzea
    Member

    The CHILD SELECTOR! Doh!… My brain is fried, no question about it.

    I was SO fixed on :nth-child…

    Thanks amigo noahgelman :)

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