Button Background Hover Effects

Awesome button background transition effect!

 Techmates    28 Jul, 2017    2705

In this article, we'd love to share a button background hover effect with you guys.

To create a background hover effect on the button, please follow these simple steps:

 

HTML

<button class="btn fade left">Hover Me!</button>
<button class="btn fade right">Hover Me!</button>
<br /><br />
<button class="btn fade top">Hover Me!</button>
<button class="btn fade bottom">Hover Me!</button>
<br /><br />
<button class="btn fade center">Hover Me!</button>
<button class="btn fade center lr">Hover Me!</button>
<button class="btn fade center tb">Hover Me!</button>

 

CSS

.btn {
  position: relative;
  display: inline-block;
  padding: 30px 25px;
  min-width: 300px;
  color: #FFF;
  text-transform: uppercase;
  font-weight: bolder;
  border: 1px solid #0073B7;
  color: #0073B7;
  border-radius: 7px;
  cursor: pointer;
  z-index: 999;
  overflow: hidden;
  transition: .5s;
}
.btn:hover {
  color: #FFF;
}
.btn:after {
  position: absolute;
  background: #0073B7;
  width: 0;
  height: 0;
  content: "";
  z-index: -1;
  transition: width .25s, height .25s;
}

.btn.fade.left:after {
  left: 0;
  top: 0;
  bottom: 0;
  height: 100%;
}

.btn.fade.right:after {
  right: 0;
  top: 0;
  bottom: 0;
  height: 100%;
}
.btn.fade.left:hover:after, .btn.fade.right:hover:after {
  width: 100%;
}

.btn.fade.top:after {
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
}
.btn.fade.bottom:after {
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
}
.btn.fade.top:hover:after, .btn.fade.bottom:hover:after {
  height: 100%;
}

.btn.fade.center:after {
  top: 50%;
  transform: translateY(-51%);
  left: 0;
  right: 0;
  margin: 0 auto;
}

.btn.fade.center.lr:after {
  height: 100%;
}
.btn.fade.center.tb:after {
  width: 100%;
}

.btn.fade.center:hover:after {
  width: 100%;
  height: 100%;
}

 

 





Related Snippets