效果:
鼠标经过前:鼠标经过后出现线性动画:
html部分:
<div class="c-btn c-btn--border-line" id="bbb">鼠标经过查看效果</div>
css部分:
#bbb{
border: 1px solid #EDEDED;
padding-left: 40px;
margin-left: 10px;
padding-right: 20px;
margin-right: 10px;
display: block;
line-height: 40px;
width: 100px;
height: 100px;
-webkit-transition: all 0.6s ease-in;
-moz-transition: all 0.6s ease-in;
-ms-transition: all 0.6s ease-in;
-o-transition: all 0.6s ease-in;
transition: all 0.6s ease-in;
}
.c-btn {
color: #ffffff;
text-decoration: none;
position: relative;
display: inline-block;
height: 100%;
}
.c-btn:after {
content: '';
display: block;
position: absolute;
}
.c-btn:before {
content: '';
display: block;
position: absolute;
}
.c-btn--border-line {
background: none;
border: 0;
box-sizing: border-box;
box-shadow: inset 0 0 0 0px transparent;
}
.c-btn--border-line:after,.c-btn--border-line:before {
box-sizing: border-box;
border: 1px solid transparent;
width: 0;
height: 0;
}
.c-btn--border-line:after {
top: 0;
left: 0;
-webkit-transition: border-color 0s ease-in 0.8s,width 0.2s ease-in 0.6s,height 0.2s ease-in 0.4s;
transition: border-color 0s ease-in 0.8s,width 0.2s ease-in 0.6s,height 0.2s ease-in 0.4s;
}
.c-btn--border-line:before {
bottom: 0;
right: 0;
-webkit-transition: border-color 0s ease-in 0.4s,width 0.2s ease-in 0.2s,height 0.2s ease-in;
transition: border-color 0s ease-in 0.4s,width 0.2s ease-in 0.2s,height 0.2s ease-in;
}
.c-btn--border-line:hover:after,.c-btn--border-line:hover:before {
width: 100%;
height: 100%;
}
.c-btn--border-line:hover:after {
border-top-color: #367dff;
border-right-color: #367dff;
-webkit-transition: width 0.2s ease-out,height 0.2s ease-out 0.2s;
transition: width 0.2s ease-out,height 0.2s ease-out 0.2s;
}
.c-btn--border-line:hover:before {
border-bottom-color: #367dff;
border-left-color: #367dff;
-webkit-transition: border-color 0s ease-out 0.4s,width 0.2s ease-out 0.4s,height 0.2s ease-out 0.6s;
transition: border-color 0s ease-out 0.4s,width 0.2s ease-out 0.4s,height 0.2s ease-out 0.6s;
}