TITLE : Fun With CSS Button Hover Effects | Advanced CSS Hover Effect | HTML and CSS
Source Code :
HTML :
<html>
<head>
<title>
Button Hover Effect
</title>
<link rel="stylesheet" href="style.css">
</head>
<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>
</html>
CSS:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Futura Md BT;
}
body{
background:#f1f1f1;
}
.container {
display: flex;
justify-content: space-evenly;
align-items: center;
height: 150px;
width: 60%;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
.btn {
padding: 7px 50px;
margin:0 10px;
background-color: #1e3e75;
color:#fff;
border:none;
outline: none;
position: relative;
z-index: 1;
}
.btn1:hover::before {
transform: scaleX(1);
transform-origin: right;
}
.btn1::before {
content: '';
position: absolute;
top:0;
left:0;
transform: scaleX(0);
transform-origin: left;
background-color: #ff4860;
width:100%;
height: 100%;
z-index: -1;
transition: 0.3s;
}
.btn2:hover::before {
transform: scaleY(1);
transform-origin: bottom;
}
.btn2::before {
content: '';
position: absolute;
top:0;
left:0;
transform: scaleY(0);
transform-origin: top;
background-color: #ff4860;
width:100%;
height: 100%;
z-index: -1;
transition: 0.3s;
}
.btn3:hover::before {
transform: scale(1);
}
.btn3::before {
content: '';
position: absolute;
top:0;
left:0;
transform: scale(0);
background-color: #ff4860;
width:100%;
height: 100%;
z-index: -1;
transition: 0.3s;
}
.btn4:hover::before {
transform: scaleX(1);
}
.btn4::before {
content: '';
position: absolute;
top:0;
left:0;
transform: scaleX(0);
background-color: #ff4860;
width:100%;
height: 100%;
z-index: -1;
transition: 0.3s;
}