Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Show div behind another div on hover

Hi! I'm doing a web page and I want to do an animation on hover; I want to rotate the div 180deg on Y axis and show another div with some text; I saw that in the CSS Foundations course with a card but now the CSS Animation module is gone :( I can´t remember how to do it, can someone help me?

Pd: I already do transform: rotateY(180deg); but I need to show another div, not the same div.

Thanks

1 Answer

Hey Juan,

What I would do is stack the two divs on top of each other with some fixed or absolute positioning. Give the div that is supposed to appear on top a higher z-index than the div on the bottom (note: z-index only works on elements that have fixed, absolute, or relative positioning). Then, target the hover pseudo element on the top div so that it rotates outward and will display the div below it.

Marcus is exactly right. For more information on the subject Check out WebPlatform's CSS Guilde to z-index