I was following a youtube tutorial, in which a CSS hover effect was used so that when you bring you cursor on the navbar items, a line emerged gradually from the center. How does the whole :hover::after thing work?
This is the CSS code they showed in the video :
nav{
display: flex;
padding: 2% 6%;
justify-content: space-between;
align-items: center;
position: sticky;
}
nav img{
width: 150px;
}
.nav-links{
flex: 1;
text-align: right;
gap: 2rem;
}
.nav-links ul li{
list-style: none;
display: inline-block;
padding: 8px 12px;
position: relative;
}
.nav-links ul li a{
color: #ffffff;
font-size: 13px;
text-decoration: none;
}
.nav-links ul li a::after{
content: '';
width: 0%;
height: 2px;
background: #f44336;
display: block;
margin: auto;
transition: 0.5s;
}
.nav-links ul li a:hover::after{
width: 100%;
}```