Skip to content
Advertisement

CSS – Issues animating child on parent hover?

I have looked at Move HTML element upwards on hover and I know how to define the CSS animation I want, however given the other animations at play in this snippet I am running into issues animating a child element on parent hover.

Snippet:

JavaScript
JavaScript

This is the animation I want to apply to only the text of the nav bar (not the animated lines) on hover of the whole <li> :

JavaScript

Without breaking the existing line animations, how can I animate move only the text of these nav items on hover of each parent <li>?

Advertisement

Answer

You could move the line drawing part to the li rather than the a element and on the a element put the translate upwards. That way you don’t have to alter the HTML.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement