h5绚丽的边框-border渐变和字体颜色渐变

1.先看效果图:
这里写图片描述
2.代码上部分注稀:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<body>
<style>
body{
    text-align: center;
}
button {
  background: none;
  border: 0;
  box-sizing: border-box;/*border和padding全会在你设置的宽高内部*/
  margin: 1em;
  padding: 1em 2em;
  box-shadow: inset 0 0 4px 3px plum;/*inset内阴影。该参数可选,不设的话默认是外阴影。*/
  color: blue;
  font-size: inherit;
  font-weight: 700;
  position: relative;
}
  button::before,
  button::after {
    box-sizing: inherit;/*继承父的*/
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
  }
.draw {
    transition: color 2s;/*字体颜色出现渐变一个用时2s*/
    }
  .draw::before,
  .draw::after {
    border: 2px solid transparent;/*边框设置为透明的*/
    width: 0;
    height: 0;
  }
  .draw::before {
    top: 0;
    left: 0;
  }
  .draw::after {
    bottom: 0;
    right: 0;
  }
  .draw:hover {
    color: black;
  }
  .draw:hover::before,
  .draw:hover::after {
    width: 100%;
    height: 100%;
  }
  .draw:hover::before {
    border-top-color: red; 
    border-right-color: red;
    transition:
      width 0.25s ease-out, /*ease-out是结束是慢的*/
      height 0.25s ease-out 0.25s; 
  }
  .draw:hover::after {
    border-bottom-color: red; 
    border-left-color: red;
    transition:
      width 0.25s ease-out 0.5s,
      height 0.25s ease-out 0.75s;
  }
</style>
<button class="draw">Draw border</button>
</body>
</html>

有用请赞一下咯!嘻嘻

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值