Jump to content
Search Community

Question cssruleplugin get pseudo-elements

daniel_pan test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi, everyone.


I read the spec and know that I can tween the css pseudo-elements (':before', ':after') using 



What if I have several elements with the same class name and all of them have pseudo-elements and I want to tween them individually? Is this possible?


I tried the CSSRulePlugin.getRule function, and the tween would change all the elements' pseudo-elements.



Thanks in advance.

Link to comment
Share on other sites

Hello daniel_pan, And welcome to the GreenSock Forum!


Do you have an example of the code you were trying, and the CSS selector being used?


In CSS if you just target using :before or :after, and it is a general CSS selector rule. It will target all :before or :after elements, or in this case the generated content in the DOM.


You would need to be more specific in your CSS selector rule, either by using a class, id or tag along with the pseudo-element. Which has to do with general CSS relating to CSS Specificity and what exactly you are directly targeting in the DOM with your CSS selector.







Also a codepen example of what your trying would be a big help so we can see your code in context. here is a video tut on how to create a codepen example



Also keep in mind that with GSAP to animate pseudo-elements you must use the old syntax of single colon ( : ) and not the new double colon ( :: ) for pseudo-elements in the CSS3 spec.


Thanks :)

  • Like 4
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...