Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
squxd

Bring to Front (Z-Index?) - SVG Hover Morph Animation

Go to solution Solved by Jonathan,

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

Hello all - 

 

I would love some help figuring out the z-index. I have everything like I want, however; the black Nike check is not moving to the front (over top of the yellow check on hover).

 

Take a peek at my codepen, any help is much appreciated!

 

Thank you!

 

nick

See the Pen BzmJkL by squxd (@squxd) on CodePen

Link to comment
Share on other sites

  • Solution

SVG 1.1 does not support CSS z-index or the SVG z-index attribute.

 

z-index only works on HTML DOM elements that have position absolute, relative, or fixed.. which use the CSS Box Model.

 

With SVG you have to rely on the order the SVG child elements appear. The last SVG child element will always have a higher z-index.

 

Your SVG child <path> element #checkE is the last element. And that element is covering up your #checkYellow <path>

 

The z-index attribute will only be available in SVG 2.0.

 

https://www.w3.org/TR/SVG2/render.html

 

So you might have to either hide #checkE or remove and prepend the SVG #checkE <path> so it is before the #checkYellow child <path> to bring it back.

 

:)

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

×