Left button fills with left to right. And right button fills top to down.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="style.css">
<style type="text/css">
body{
margin: 0;
padding: 0;
}
.middle{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
text-align: center;
}
.btn{
background: none;
border: 2px solid #000;
font-family: "montserrat",sans-serif;
text-transform: uppercase;
padding: 12px 20px;
min-width: 200px;
margin: 10px;
cursor: pointer;
transition: color 0.4s linear;
position: relative;
}
.btn:hover{
color: #fff;
}
.btn::before{
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #000;
z-index: -1;
transition: transform 0.5s;
transform-origin: 0 0;
transition-timing-function: cubic-bezier(0.5,1.6,0.4,0.7);
}
.btn1::before{
transform: scaleX(0);
}
.btn2::before{
transform: scaleY(0);
}
.btn1:hover::before{
transform: scaleX(1);
}
.btn2:hover::before{
transform: scaleY(1);
}
</style>
</head>
<body>
<div class="middle">
<button class="btn btn1">Hover Me</button>
<button class="btn btn2">Hover Me</button>
</div>
</body>
</html>