Underline Animation Effect on hover the text using simple css

Using css we can animated several things, This is one of the different and interesting thinking to animated text underline bar with gradient with animation effect. Now will see how to create underline animation effect on hover the underline text using css.

In this underline animation the underline bar background gradient moves the left to right with different gradient background colors. You can change the gradient background colors by changing the background color codes in the below example code

background: linear-gradient(to bottom, rgba(20, 20, 20, 0.8), rgba(20, 20, 20, 0.8)) center 1.08em/100% 

This types of effects is really different thinking. Here is the full code for how to do the underline animation effect on hover the text using the simple css, You can download the full code here to use this underline animation. And also having the demo links to display the result of this example. I hope this example really helpful.

Html code for Underline Animation Effect on hover the text :

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Underline Animation Effect on hover the text using simple css</title>
<link rel="stylesheet" href="css/style.css">  
</head>
<body>
<div class="page-example">
<a href="http://www.sanwebcorner.com" target="_blank">Underline Gradient Animation Effect<br/></a>
</div>
<br/> <br/>
<div class="page-example">
<a href="http://www.sanwebcorner.com" target="_blank">Underline Gradient Animation Effect on hover<br/></a>
<br/><br/>
</div>

<div class="page-example">
<h2><a href="http://www.sanwebcorner.com">www.sanwebcorner.com</a></h2>
<br/><br/>
</div>
</body>
</html>

Css Code for Underline Animation Effect on hover the text :

html{

line-height: 1.15;
}

a {
color: transparent;
display: inline-block;
overflow: hidden;
position: relative;
text-decoration: none;
text-shadow: 0 0 #141414, 0.08em 0 0 #fff, 0 0, -0.08em 0 0 #fff;
vertical-align: bottom;
}
a:after {
background: linear-gradient(to bottom, rgba(20, 20, 20, 0.8), rgba(20, 20, 20, 0.8)) center 1.08em/100% 5px no-repeat;
content: "";
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 400%;
will-change: transform;
z-index: -1;
}
a:hover:after {
-webkit-animation: underline-gradient 6s linear infinite;
animation: underline-gradient 6s linear infinite;
background-image: linear-gradient(90deg, rgba(122, 95, 255, 0.8) 15%, rgba(1, 255, 137, 0.6) 35%, rgba(122, 95, 255, 0.8) 85%);
}

@-webkit-keyframes underline-gradient {
0% {
-webkit-transform: translate3d(0%, 0%, 0);
transform: translate3d(0%, 0%, 0);
}
100% {
-webkit-transform: translate3d(-75%, 0%, 0);
transform: translate3d(-75%, 0%, 0);
}
}

@keyframes underline-gradient {
0% {
-webkit-transform: translate3d(0%, 0%, 0);
transform: translate3d(0%, 0%, 0);
}
100% {
-webkit-transform: translate3d(-75%, 0%, 0);
transform: translate3d(-75%, 0%, 0);
}
}
/* page layout */
html,
body {
height: 90%;
}


.page-example {
font-size: 3vw;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
text-align: center;
}

Post a Comment

0 Comments