Jump to content
Search Community

I'm having trouble with the selectors

cagkebabi test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

If I select the li element in the tween css selection in forEach, I have no problems, but when I select the a element in li, I have problems. Can you support me in this regard?

 

I solved the problem by applying color inherit for a, but I wonder the cause of the problem

See the Pen OJYmzxg by CagKebabi (@CagKebabi) on CodePen

Link to comment
Share on other sites

  • Solution

Hi @cagkebabi welcome to the forum!

 

That is correct. when you use :nth-child() selectors they all need to be children on the same level. Where your <li> elements are all children of the ul.navs your <a> elements are children of your <li>, and if you could how many children there are in your <li> it will only ever be one. This has nothing to do with GSAP, but is how CSS works. You can however use the same :nth-child() selector, but then select the <a> inside that. Still just CSS and nothing special in GSAP. Hope it helps and happy tweening! 

 

See the Pen pomPpaO?editors=1010 by mvaneijgen (@mvaneijgen) on CodePen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...