<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> CSS Border Hover Animation </title>
</head>
<body>
<div class="container">
<button class="btn-3"><span>Hover Me</span></button>
</div>
</body>
</html>
*, *:after, *:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body{
font-family: 'PT Sans', sans-serif;
display: table;
width: 100%;
background: rgba(0,0,0,0.09);
}
.container{
display: table-cell;
vertical-align: middle;
text-align: center;
height: 100vh;
}
button{
display: inline-block;
position: relative;
background: none;
border: none;
color: #fff;
font-size: 18px;
cursor: pointer;
margin: 20px 30px;
background: rgba(0,0,0,0.06);
}
span{
display: block;
padding: 25px 80px;
}
button::before, button::after{
content:"";
width: 0;
height: 2px;
position: absolute;
transition: all 0.2s linear;
background: #fff;
}
span::before, span::after{
content:"";
width:2px;
height:0;
position: absolute;
transition: all 0.2s linear;
background: #fff;
}
button:hover::before, button:hover::after{
width: 100%;
}
button:hover span::before, button:hover span::after{
height: 100%;
}
span::after{
height:50%;
}
.btn-3::after{
right:0;
bottom: 0;
width:30%;
transition-delay: 0.6s;
}
.btn-3 span::after{
transition-delay: 0.4s;
right: 0;
bottom: 0
}
.btn-3::before{
right: 0;
top: 0;
transition-delay: 0.2s;
}
.btn-3 span::before{
transition-delay: 0s;
left: 0;
top: 0;
}
.btn-3:hover::after{
transition-delay: 0s;
}
.btn-3:hover span::after{
transition-delay: 0.2s;
}
.btn-3:hover::before{
transition-delay: 0.4s;
}
.btn-3:hover span::before{
transition-delay: 0.6s;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.