I've been working on a navbar design and I'm having trouble getting the hover effect to work on the links. Specifically, I am trying to add a transform property to the after
element of the links but it doesn't seem to be taking effect.
#navbar {
display: flex;
justify-content: space-between;
align-items: center;
}
.link-list {
display: flex;
gap: 2rem;
}
.menu-link {
color: var(--white);
text-decoration: none;
position: relative;
}
.menu-link::after { /*this is for the bottom border line which is 25% in length*/
background: var(--white);
content: "";
width: 50%;
height: 2px;
position: absolute;
left: 25%;
bottom: -4px;
transform: scaleX(0); /*i am adding transform 0 */
transform-origin: center;
transition: transform 500ms ease;
}
.menu-link:hover .menu-link::after{ /* unable to get this effect on hover */
transform: scaleX(1);
}
Here are the link lists:
<section class="link-list">
<a href="#" class="menu-link">About</a>
<a href="#" class="menu-link">Careers</a>
<a href="#" class="menu-link">Events</a>
<a href="#" class="menu-link">Products</a>
<a href="#" class="menu-link">Explore</a>
</section>