top of page
Search
Writer's pictureAchyuth

Buttons Hover Slide Animation Left Right Bottom Top | CSS button animations| CodingTutorialSS

Updated: Apr 3


HTML:

<div class="playground">
<button class="btn1">Left</button>
<button class="btn2">Right</button>
<button class="btn3">Bottom</button>
<button class="btn4">Top</button>
</div>

CSS:

.playground {
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
}
button {
  font-size: 40px;
  font-weight: bold;
  margin: 20px;
  padding: 10px;
  width: 200px;
  border: 1px solid #DDD;
  transition: all .5s ease-out;
  color: #273c75;
}
button:hover{
  color: #FFF;
}
.btn1{
   background: linear-gradient(to right, #e84118 50%, #FFF 50%);
  background-size: 200% 100%;
  background-position: right;
}
.btn2{
   background: linear-gradient(to right, #FFF 50%, #e84118 50%);
   background-size: 200% 100%;
  background-position: left;
}
.btn3{
     background: linear-gradient(to top, #e84118 50%, #FFF 50%);
  background-size: 100% 200%;
  background-position: top;
}
.btn4{
     background: linear-gradient(to top, white 50%, #e84118 50%);
  background-size: 100% 200%;
  background-position: bottom;
}
.btn1:hover{
  background-position: left;
}
.btn2:hover{
  background-position: right;
}
.btn3:hover{
  background-position: bottom;
}
.btn4:hover{
  background-position: top;
}

Demo:



472 views1 comment

1 Comment


sathish
Oct 24

Ho w can i add it to WIX studio


Like
bottom of page