2019-08-06
描述
当鼠标移上时,创建一个边框的动画。
HTML
<div class="button-border"><button class="button">Submit</button></div>
CSS
.button {
  background-color: #c47135;
  border: none;
  color: #ffffff;
  outline: none;
  padding: 12px 40px 10px;
  position: relative;
}
.button:before,
.button:after {
  border: 0 solid transparent;
  transition: all 0.25s;
  content: '';
  height: 24px;
  position: absolute;
  width: 24px;
}
.button:before {
  border-top: 2px solid #c47135;
  left: 0px;
  top: -5px;
}
.button:after {
  border-bottom: 2px solid #c47135;
  bottom: -5px;
  right: 0px;
}
.button:hover {
  background-color: #c47135;
}
.button:hover:before,
.button:hover:after {
  height: 100%;
  width: 100%;
}
Demo
说明
当鼠标移上时,使用 :before 和 :after 伪元素做为边框以实现动画效果。
浏览器支持
支持率:100%
 
         ME!
                
                ME!
             链滴
                
                链滴