Forums

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

Home Forums CSS nth-child()

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

    Hi, I am trying to accesses each article using nth-child to give them there own hover color, however nothing I have tried works, could anyone show me how to correctly use nth-child to target each article from the HTML below.

    	


    Example




    Test



    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non libero neque. Etiam nulla nunc, bibendum vel lobortis vel, fringilla sed magna.






    Test


    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non libero neque. Etiam nulla nunc, bibendum vel lobortis vel, fringilla sed magna.







    Test



    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non libero neque. Etiam nulla nunc, bibendum vel lobortis vel, fringilla sed magna.







    Test



    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non libero neque. Etiam nulla nunc, bibendum vel lobortis vel, fringilla sed magna.







    Test



    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non libero neque. Etiam nulla nunc, bibendum vel lobortis vel, fringilla sed magna.







    Test



    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non libero neque. Etiam nulla nunc, bibendum vel lobortis vel, fringilla sed magna.





    Thanks for any help

    #99553
    Paulie_D
    Member

    You haven’t posted the CSS but I would suggest that the article-wrapper divs are unnecessary and may be the root cause of why the nth-child isn’t working.

    #99556
    Paulie_D
    Member

    Here’s Chris’ article on it: https://css-tricks.com/how-nth-child-works/

    Actually, I think you’re probably after nth-of-type..see: http://jsfiddle.net/Paulie_D/ANuN3/

    #99574
    TheDoc
    Member

    If you want to use nth-child you could do something like this:

    .article-wrapper:nth-child(##) article { }
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.