<!-- ------------------- Created By InCoder ------------------- -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Cool Button Background Animation - InCoder</title>
  <link rel="stylesheet" href="main.css">
</head>

<body>
  <div class="wrapper">
    <a href="#" class="inBtn inBtn-green mr-3">Submit</a>
    <a href="#" class="inBtn inBtn-red">Submit</a>
  </div>
</body>

</html>
/* ------------------- Created By InCoder ------------------- */

* {
  margin: 0;
  padding: 0;
}

body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #e6e6e6;
}

.wrapper {
  width: 30rem;
  display: flex;
  height: 15rem;
  margin: 2rem 1rem;
  border-radius: 8px;
  align-items: center;
  background-color: #fff;
  justify-content: center;
  transition: box-shadow 0.2s;
  box-shadow: 2px 2px 15px rgba(0, 0, 0, 0.1);
}

.wrapper:hover {
  box-shadow: 2px 2px 15px rgba(0, 0, 0, 0.2);
}

.inBtn {
  border: 0px;
  z-index: 1;
  color: #fff;
  overflow: hidden;
  font-size: 1.2rem;
  position: relative;
  border-radius: 6px;
  padding: 0.8rem 2rem;
  text-decoration: none;
  background-position: 5rem;
  text-transform: capitalize;
}

.inBtn::before {
  content: "";
  top: 0%;
  left: -100%;
  z-index: -1;
  width: 100%;
  height: 100%;
  color: #fff;
  position: absolute;
  transition: left 0.4s;
  background-color: #202020;
}

.inBtn:hover::before {
  left: 0%;
}

.mr-3 {
  margin-right: 20px;
}

.inBtn-green {
  background-color: #22ba87;
}

.inBtn-red {
  background-color: #e03652;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.