I’ve got this html
<ul class="flex gap-3"><li class="after:content-[''] after:block after:w-0 after:h-2 after:bg-black hover:after:w-full transition duration-1000 ease-in-out"><a href="/" class="text-lg font-bold text-black uppercase" > home </a></li></ul>
on hover I’d like to apply transition for a nice animation
but there is no animation
Could you help me, please?
2
Answers
A couple of changes are needed:
transition
class in TailwindCSS transitions: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter. It doesn’t transition width. So you can change that to either betransition-all
ortransition-[width]
.after:transition-all after:duration-1000 after:ease-in-out
Working snippet:
You could refer to this Tailwind documentation: https://tailwindcss.com/docs/hover-focus-and-other-states
Anyway, I tried modifying your code into this:
So you could further stack pseudo classes in TailwindCSS like
hover:after:some-tw-class
I hope this helps.