HTML/CSS Buttons with hover animation effects

  • Last updated: Nov 3, 2023
  • Views: 248
  • Author: Admin
HTML/CSS Buttons with hover animation effects

Hello colleagues.

Today we'll show you how to create buttons with hover animation effects using pure HTML and CSS.

 

HTML Code:

<body>
<div class="container">
    <button class="btn btn1">Button 1</button>
    <button class="btn btn2">Button 2</button>
    <button class="btn btn3">Button 3</button>
    <button class="btn btn4">Button 4</button>
</div>
</body>

 

CSS Code:

body{
    margin: 0;
    padding: 0;
    background-color: #DED7E6;
}
.container{
    text-align: center;
    margin-top: 360px;
}
.btn{
    border: 1px solid #776F70;
    background: none;
    padding: 25px 50px;
    font-size: 20px;
    letter-spacing: 8px;
    font-family: "montserrat";
    cursor: pointer;
    margin: 10px;
    transition: 0.5s;
    position: relative;
    overflow: hidden;
    border-radius: 5px;
}
.btn1,.btn2{
    color: #776F70;
}
.btn3,.btn4{
    color: #DED7E6;
}
.btn1:hover,.btn2:hover{
    color: #DED7E6;
}
.btn3:hover,.btn4:hover{
    color: #776F70;
}
.btn::before{
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 0%;
    background: #776F70;
    z-index: -1;
    transition: 0.8s;
}
.btn1::before,.btn3::before{
    top: 0;
    border-radius: 0 0 50% 50%;
}
.btn2::before,.btn4::before{
    bottom: 0;
    border-radius: 50% 50% 0 0;
}
.btn3::before,.btn4::before{
    height: 180%;
}
.btn1:hover::before,.btn2:hover::before{
    height: 180%;
}
.btn3:hover::before,.btn4:hover::before{
    height: 0%;
}

 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

YII2 defaultRoute - How to change default controller in template

YII2 defaultRoute - How to change default controller in template

Pure HTML/CSS search bar

Pure HTML/CSS search bar

HTML/CSS - Expandable Searchbar Animation

HTML/CSS - Expandable Searchbar Animation