HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content
="width=device-width, initial-scale=1.0">
<title>Animated Hover Button </title>
</head>
<body>
<button class="btn">Hover Me ! </button>
</body>
</html>
CSS
/*Style the menu items */
body {
background: #161616 ;
display: flex ;
align-items: center ;
justify-content: center ;
min-height : 100vh ;
width: 100% ;
}
.btn {
margin: 100px ;
border: none ;
color: #fff ;
cursor: pointer ;
position: relative ;
z-index: 0 ;
font-size: 29px ;
border-radius : 10px ;
padding : 15px 38px ;
box-shadow : 0 6px 20px rgba(0, 0, 0, 0.3) ;
}
.btn::after {
content: '' ;
z-index : -1 ;
position : absolute ;
width : 100% ;
height : 100% ;
background : #333 ;
left : 0 ;
top : 0 ;
border-radius : 10px ;
}
/* Change color */
btn ::before {
content: "" ;
background : linear-gradient(45deg,#FF0000,#FF7300,#FFFB00,#48FF00,#00FFD5,#002BFF,#FF00CB,#FF0000) ;
position : absolute ;
left : -2px ;
left : -2px ;
background-size : 600% ;
z-index : -1 ;
width : calc(100% + 4px) ;
height : calc(100% + 4px) ;
filter : blur(8px) ;
animation : glow 18s linear infinite ;
transition : opacity 0.3s ease-in-out ;
border-radius : 10px ;
opacity : 0 ;
}
@keyframes glow {
0% {
background-position : 0 0 ;
}
50% {
background-position : 100% 0 ;
}
}
/* Change color on hover */
.btn :hover::before {
opacity : 1 ;
}
.btn :active::before {
background : transparent ;
}
.btn :active {
background : transparent ;
}