Jump to content
Search Community

overriding !important with Greensock

pauljohnknight test
Moderator Tag

Go to solution Solved by OSUblake,

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

 

I’m trying to Tween the background color of an element on a WordPress site which has the !important rule assigned to it.

 

How can I override this?  I’ve tried both of the following and neither work.

var colorChange = TweenMax.to ('#box1', 1, {backgroundColor: 'black !important'});

var colorChange = TweenMax.to ('#box1', 1, {backgroundColor: 'black’ });

I tried and tested changing the background color in my child theme CSS and this works as expected, but not when used with Greensock.

 

 All other elements on the page animate fine with Greensock that don’t have the !important tag?

 

Any help would great.

 

Paul

Link to comment
Share on other sites

The CSS !important declaration should only be used in your external style-sheet or within in a style tag, never inline on a style attribute!

 

Just as Blake advised either be more specific with your CSS selector rule inside your external style-sheet along with the !important declaration to override the existing rule. Or override the inline style with another CSS property value using the CSSRulePlugin.

 

:)

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