Jump to content
Search Community

zIndex reset after hover off

wrongholt 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

So I am trying to get hover on and off to work with zIndex.  I have attached my code pen forgive me if there are some errors it was my first time creating one.  I have images that are overlapped like on the code Pen and I want the zIndex to come forward (hover on)and than reset after (hovering off).  I originally have the zIndexes set on the images(in CSS) prior to messing with them in JS.  Any help would be greatly appreciated.

See the Pen WEpLQO by wrongholt (@wrongholt) on CodePen

Link to comment
Share on other sites

Hi @wrongholt :)

 

Welcome to the forum.

 

Just a couple changes and you'll be good to go. Your selector should change:

// switch this
var thumbs = document.querySelectorAll('#redBox', "blueBox");
//to this
var thumbs = document.querySelectorAll( "#blueBox, #redBox");

 

Then you can clearProps of the zIndex when you hover off the element. Here's a fork of your pen:

 

See the Pen gxmqrv by PointC (@PointC) on CodePen

Hopefully that helps.

 

Happy tweening.

:)

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