HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Button Hover Effect</title>
<link rel="stylesheet" href="style.css">
<!-- Required Meta Tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- GOOGLE FONTS -->
<link href="https://fonts.googleapis.com/css?family=Orbitron|Anton|Cabin|Lato|Fjalla+One|Montserrat|Roboto&display=swap" rel="stylesheet">
</head>
<body>
<a href="#" class="btn vertical">Hover Me</a>
<a href="#" class="btn horizontal">Hover Me</a>
<a href="#" class="btn side-wise1">Hover Me</a>
<a href="#" class="btn side-wise2">Hover Me</a>
</body>
</html>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #2d3436;
}
.btn {
position: relative;
font-family: "Roboto", serif;
text-decoration: none;
font-size: 20px;
font-weight: bolder;
letter-spacing: 1px;
text-transform: uppercase;
padding: 20px 60px;
margin: 0 20px;
color: white;
border: 2px solid darkcyan;
overflow: hidden;
transition: all 0.6s ease 0s;
}
.btn::before{
content:"";
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
transform: translate(-50%, -50%);
background: darkcyan;
transition: all 0.6s ease 0s;
}
.vertical::before {
width: 100%;
height: 0;
}
.vertical:hover::before {
height: 100%;
}
.horizontal::before {
height: 100%;
width: 0;
}
.horizontal:hover::before {
width: 100%;
}
.side-wise1::before {
width: 100%;
height: 0;
transform: translate(-50%, -50%) rotate(45deg);
}
.side-wise1:hover::before {
height: 380%;
}
.side-wise2::before {
width: 100%;
height: 0;
transform: translate(-50%, -50%) rotate(-45deg);
}
.side-wise2:hover::before {
height: 380%;
}