How To Build Button Hover Animation with HTML & CSS

RH Suman
June 20, 2022

53

Easy but eye catching CSS submit buttons hover effects, by animating the “:before” and “:after” pseudo elements.

HTML Code:

  <div class="container">
    <a href="#" class="btn btn-1">Button Hover</a>
  </div>

CSS Code:

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body{
  background-color: #229955;
}
.container{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.btn{
  color: #fff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 20px;
  max-width: 200px;
  display: block;
  position: relative;
  line-height: 45px;
  padding: 5px 10px;
}
.btn-1{
  border: 1px solid;
  overflow: hidden;
  position: relative;
}
.btn-1:before{
  content: '';
  position: absolute;
  top: -50px;
  left: -100px;
  width: 50px;
  height: 150px;
  background-color: #fff;
  transform: rotate(45deg);
  opacity: .2;
  transition: .6s;
}
.btn-1:hover:before{
  left: 150px;
}

Preview

Tags

Animation Hover CSS CSS Animation

Subscribe

Get Updates

Subscribe our newsletter to get the last update into your inbox!

Please insert email address.

Recommended Posts