基于Less封裝的按鈕動畫

今天沒什么事情,基于less做了個按鈕動畫。直接上代碼吧!

.colorBtn(@color) {
    background: @color;
    &:hover {
        color: @color;
        &:before,
        &:after {
            background: @color;
        }
    }
}
.li-btn {
  text-decoration: none;
  font-size: 14px;
  color: #fff;
  padding: 14px 36px;
  border-radius: 8px;
  border: none;
  outline: none;
  margin-right: 25px;
  transition: 600ms ease all;
  position: relative;
  display: inline-block;
  &:hover {
    background: #fff;
    &:before, &:after {
      width: 100%;
      transition: 600ms ease all;
    }
  }
  &:before, &:after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    height: 2px;
    width: 0;
    transition: 400ms ease all;
  }
  &::after {
    right: inherit;
    top: inherit;
    left: 0;
    bottom: 0;
  }
}

.pink-btn{
  .colorBtn(#E65D6E);
 }
.blue-btn{
  .colorBtn(#324157);
 }

 .light-blue-btn{
  .colorBtn(#3A71A8);
  
 }
 .red-btn {
    .colorBtn(#C03639)
}

.yellow-btn {
  .colorBtn(#FEC171)
}
.green-btn{
  .colorBtn(#30B08F);
 }
//使用的話 直接引入Less文件
@import '../../public/less/btn.less';
//頁面上這樣寫
<router-link class="li-btn blue-btn" to="/components/index">合同信息查詢</router-link>
<router-link class="li-btn light-blue-btn" to="/charts/index">添加訂單</router-link>
<router-link class="li-btn pink-btn" to="/excel/download">采購單查詢</router-link>
<router-link class="li-btn green-btn" to="/example/table/table">部件信息查詢</router-link>

gif.gif
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容