Today I will be teaching you how to create a underline transition effect for your website using CSS animation
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>Click Me</p>
</body>
</html>
CSS
*{
padding: 0;
margin: 0;
}
body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #0A0A0A;
}
p{
font-size: 128px;
position: absolute;
border-bottom: 4px solid rgba(255, 224, 2, 0);
color: #FFE002;
}
p:hover{
cursor: pointer;
animation-name: underlineTransition;
animation-duration: 1s;
animation-timing-function: linear;
animation-fill-mode: forwards;
}
@keyframes underlineTransition{
0% {border-bottom: 4px solid rgba(255, 224, 2, 0);}
25% {border-bottom: 4px solid rgba(255, 224, 2, 0.25);}
50% {border-bottom: 4px solid rgba(255, 224, 2, 0.5);}
75% {border-bottom: 4px solid rgba(255, 224, 2, 0.75);}
100% {border-bottom: 4px solid rgba(255, 224, 2, 1);}
}
If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on
YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ
Instagram: https://www.instagram.com/coding_for_the_web/
Twitter: https://twitter.com/LearnWebCoding
Comentarios