【css】光雾边框动画

会有动画效果,光雾的渐变动画。

代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>

  <style>
    :root {
      --shadow-size-w: 200px;
      --shadow-size-h: 100px;
    }

    body {
      background: black;
    }

    .pill {
      position: relative;
      height: 60px;
      flex: 1;
      margin: 10px;


    }

    .pill > .content {
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      border-radius: 12px;
      overflow: hidden;
      display: flex;

    }

    .pill > .content > .key {
      flex: 1;
      color: #c8b1e7;

      font-size: 18px;
      display: flex;
      overflow: hidden;
      flex-direction: row; /*默认也是row可以不写*/
      align-items: center; /*这种情况是垂直居中*/
      justify-content: center; /*这种情况是水平居中*/
      background-color: #732e96;


    }

    .pill > .content > .key > div {

    }

    .pill > .content > .key > div:after {
      content: ":";
    }

    .pill > .content > .value {
      margin-left: 2px;
      flex: 1;
      background-color: #500561;

      display: flex;
      overflow: hidden;
      flex-direction: row; /*默认也是row可以不写*/
      align-items: center; /*这种情况是垂直居中*/
      justify-content: center; /*这种情况是水平居中*/
    }

    .pill > .content > .value > div {
      color: #e200ff;
      font-size: 36px;
      font-weight: bolder;
    }

    .pill > .content > .value > div:after {
      content: "%";
      font-size: 12px;
      font-weight: normal;
    }

    .pill:before {
      content: '';
      position: absolute;
      z-index: -1;
      display: block;
      border-radius: 12px;
      left: -2px;
      top: -2px;
      bottom: -2px;
      right: -2px;
      background-image: radial-gradient(#c100ff 30%, rgba(65, 157, 129, 0.13) 60%, transparent), linear-gradient(#7c4393, #4d15f5);
      background-size: var(--shadow-size-w) var(--shadow-size-h), 100% 100%;
      background-repeat: no-repeat;
      background-position: calc(var(--shadow-size-w) / -2) calc(var(--shadow-size-h) / -2), 0 0;
      animation: infinite 3s run linear;
    }

    @keyframes run {
      0% {
        background-position: calc(var(--shadow-size-w) / -2) calc(var(--shadow-size-h) / -2), 0 0;
      }
      25% {
        background-position: calc(100% + calc(var(--shadow-size-w) / 2)) calc(var(--shadow-size-h) / -2), 0 0;
      }
      50% {
        background-position: calc(100% + calc(var(--shadow-size-w) / 2)) calc(100% + calc(var(--shadow-size-h) / 2)), 0 0;

      }
      75% {
        background-position: calc(var(--shadow-size-w) / -2) calc(100% + calc(var(--shadow-size-h) / 2)), 0 0;

      }
      100% {
        background-position: calc(var(--shadow-size-w) / -2) calc(var(--shadow-size-h) / -2), 0 0;

      }
    }
  </style>
</head>
<body>
<div style="width: 800px;margin: 0 auto;display: flex">
  <div class="pill">
    <div class="content">
      <div class="key">
        <div>药丸</div>
      </div>
      <div class="value">
        <div>99</div>
      </div>
    </div>
  </div>
  <div class="pill">
    <div class="content">
      <div class="key">
        <div>药丸</div>
      </div>
      <div class="value">
        <div>99</div>
      </div>
    </div>
  </div>
  <div class="pill">
    <div class="content">
      <div class="key">
        <div>药丸</div>
      </div>
      <div class="value">
        <div>99</div>
      </div>
    </div>
  </div>
  <div class="pill">
    <div class="content">
      <div class="key">
        <div>药丸</div>
      </div>
      <div class="value">
        <div>99</div>
      </div>
    </div>
  </div>
</div>


</body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值