Jump to content
Search Community

How to target pseudo element (eg. :before, :after) in v3?

n.watanabe

Go to solution Solved by OSUblake,

Recommended Posts

Posted

Hi. I have a question about how to target :before element and run a tween on it, and need help to run my codepen demo.

 

I found some people have shown a demo targeting ".class:before"[1][2][3][4], and came across a website[5] that is apparently using GSAP and targeting :before element. However, I also found other people said it is impossible[6], and my codepen demo doesn't work. Can anyone fix my codepen to target :before element?

 

I'm using the latest version of GSAP ("gsap": "^3.9.1") with nextjs for my production environment. Thank you in advance.

 

[1] 

[2]

[3]

[4] 

[5] https://giginc.co.jp/

[6]

 

See the Pen MWrerqV?editors=1111 by asterisk37n (@asterisk37n) on CodePen.

  • Solution
Posted

Welcome to the forums @n.watanabe

 

There was the CSSRulePlugin, but it's very limited as you can only target rules and not elements. I would recommend using CSS variables instead.

 

See the Pen VwyjQEp by GreenSock (@GreenSock) on CodePen.

 

  • Like 4
Posted

Thank you so much. For people visiting this question, I leave a document about changing CSS variables.

 

  • Like 2

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...