Heady_Button

A custom parallax button.

by Pete Fecteau

HTML

<script src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<button type="button" class="heady-button" href="http://google.com/">SUBMIT</button>

CSS

html, body {
    margin: 0;
    padding: 20px;
    height: 100%;
    width: 100%;
}
.heady-button {
  position: relative;
  display: block;
  box-sizing: border-box;
  border: 0;
  padding: 10px 20px;
  color: #fff;
  font-weight: bold;
  letter-spacing: 1px;
  background: url('http://fecteau.me/wp-content/uploads/custom/heady_0.png');
  background-size: cover;
  background-color: #182421;
  background-repeat: no-repeat;
  background-position: 100% 5px;
  cursor: pointer;
  z-index: 1;
}
.heady-button.hover {
  animation-duration: 2.5s;
  animation-name: TreesIn;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}
.heady-button::after {
  content: "";
  display: inline-block;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100%;
  width: 101%;
  background: url('http://fecteau.me/wp-content/uploads/custom/heady_1.png');
  background-size: 100% auto;
  background-color: rgba(255, 255, 255, 0);
  background-repeat: no-repeat;
  background-position: 100% -50%;
  z-index: 2;
}
.heady-button.hover::after {
  animation-duration: 3s;
  animation-name: FogIn;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

@keyframes FogIn {
  0% {
    background-position: 100% -50%;
    background-color: rgba(255, 255, 255, 0);
  }
  75% {
    background-color: rgba(255, 255, 255, 0);
  }
  100% {
   background-position: 100% 100%;
   background-color: rgba(255, 255, 255, 1);
  }
}
@keyframes FogOut {
  0% { background-position: 100% 100%; }
  100% { background-position: 100% -50%; }
}
@keyframes TreesIn {
  0% {
    background-position: 100% 5px;
    color: #fff;
    }
  100% {
    background-position: 100% 100%;
    color: #00472c;
    }
}

JavaScript

jQuery(document).ready(function() {
  $( ".heady-button" ).hover(function() {
    $(this).toggleClass('hover');
  });
})