纯CSS制作赛博朋克2077“故障风”按钮

<!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>Document</title>

  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" rel="stylesheet">
  <style>
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      background-color: #F8F005;
    }

    button,
    button::after {
      width: 380px;
      height: 86px;
      font-size: 36px;
      font-family: 'Bebas Neue', cursive;
      background: linear-gradient(45deg, transparent 5%, #FF013C 5%);
      border: 0;
      color: #fff;
      letter-spacing: 3px;
      line-height: 88px;
      box-shadow: 6px 0px 0px #00E6F6;
      outline: transparent;
      position: relative;
    }

    button::after {
      /* clip-path:剪裁   inset() : 定义一个矩形  */
      /* inset()可以传入5个参数,分别对应top,right,bottom,left的裁剪位置,round radius(可选,圆角) */
      --slice-0: inset(50% 50% 50% 50%);
      --slice-1: inset(80% -6px 0 0);
      --slice-2: inset(50% -6px 30% 0);
      --slice-3: inset(10% -6px 85% 0);
      --slice-4: inset(40% -6px 43% 0);
      --slice-5: inset(80% -6px 5% 0);

      content: 'coding FunTime';
      display: block;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(45deg, transparent 3%, #00E6F6 3%, #00E6F6 5%, #FF013C 5%);
      text-shadow: -3px -3px 0px #F8F005, 3px 3px 0px #00E6F6;
      clip-path: var(--slice-0);
      transform: translate(100px, -110px);
    }

    button:hover::after {
      animation: 1s glitch;
      /* 添加步长 增加故障 */
      animation-timing-function: steps(2, end);  
    }

    @keyframes glitch {
      0% {
        clip-path: var(--slice-1);
        transform: translate(-20px, -10px);
      }

      10% {
        clip-path: var(--slice-3);
        transform: translate(10px, 10px);
      }

      20% {
        clip-path: var(--slice-1);
        transform: translate(-10px, 10px);
      }

      30% {
        clip-path: var(--slice-3);
        transform: translate(0px, 5px);
      }

      40% {
        clip-path: var(--slice-2);
        transform: translate(-5px, 0px);
      }

      50% {
        clip-path: var(--slice-3);
        transform: translate(5px, 0px);
      }

      60% {
        clip-path: var(--slice-4);
        transform: translate(5px, 10px);
      }

      70% {
        clip-path: var(--slice-2);
        transform: translate(-10px, 10px);
      }

      80% {
        clip-path: var(--slice-5);
        transform: translate(20px, -10px);
      }

      90% {
        clip-path: var(--slice-1);
        transform: translate(-10px, 0px);
      }

      100% {
        clip-path: var(--slice-1);
        transform: translate(0);
      }
    }
  </style>
</head>

<body>

  <button>coding FunTime</button>

</body>

</html>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值