Here we have created 4 beautiful CSS Button with Hover Effects by using before pseudo-elements CSS. We made simple sliding buttons and ripple effect buttons with pure CSS3.
HTML
<div class="btn-list">
<button class="button button1">Hover Me</button>
<button class="button button2">Hover Me</button>
<button class="button button3">Hover Me</button>
<button class="button button4">Hover Me</button>
</div>
CSS
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body{
margin: 0;
padding: 0;
font-family: arial;
}
.btn-list {
margin: 0 auto;
width: 170px;
}
.button {
background: transparent;
padding: 12px 30px;
font-size: 18px;
cursor: pointer;
border-radius: 60px;
transition: 1s;
position: relative;
display: block;
overflow: hidden;
margin: 30px 10px;
}
.button1,.button2{
color: #3498db;
}
.button3,.button4{
color: #fff;
}
.button1:hover,.button2:hover{
color: #fff;
}
.button3:hover,.button4:hover{
color: #3498db;
}
.button::before{
content: "";
position: absolute;
left: 0;
width: 100%;
height: 0%;
background: #3498db;
z-index: -1;
transition: 0.8s;
}
/*---- Add Buttons ::Before Property ----*/
.button1::before,.button3::before{
top: 0;
}
.button2::before,.button4::before{
bottom: 0;
border-radius: 50% 50% 0 0;
}
.button3::before,.button4::before{
height: 180%;
}
/*---- Buttons Hover Effects----*/
.button1:hover::before,.button2:hover::before{
height: 150%;
}
.button3:hover::before,.button4:hover::before{
height: 0%;
}