css颜色无限变化, 随机

<!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>
  <style>
    #test {
      animation: change 3s linear 0s infinite;
    }

    @keyframes change {
      0% {
        color: #333;
        background-color: aqua;
      }
      50% {
        color: #f60;
        background-color: #f60;
      }
      100% {
        color: #f00;
        background-color: aquamarine;
      }
    }
  </style>
</head>

<body>
  <div id="test">这里是内容</div>
</body>

</html>

```xml
<!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>
  <style>
    body {
      position: relative;
    }

    .test {
      position: absolute;
    }

    .test1 {
      top: 100px;
      left: 100px;
    }

    .test2 {
      top: 250px;
      left: 300px;
    }

    .test3 {
      top: 410px;
      left: 320px;
    }

    .test4 {
      top: 320px;
      left: 120px;
    }

    .change {
      animation: change 3s linear 0s infinite;
    }

    @keyframes change {
      0% {
        opacity: 0;
        transform: scale(0.5);
      }

      25% {
        opacity: 0.5;
        transform: scale(1);
      }

      50% {
        opacity: 1;
        transform: scale(1.5);
      }

      75% {
        opacity: 0.5;
        transform: scale(1);
      }

      100% {
        opacity: 0;
        transform: scale(0.5);
      }
    }
  </style>
</head>

<body>
  <div class="test test1">这里是内容1</div>
  <div class="test test2">这里是内容2</div>
  <div class="test test3">这里是内容3</div>
  <div class="test test4">这里是内容4</div>
  <script src="http://localhost:8086/adap/ta/resource/face1.1.0/support/jquery/jquery-1.11.0.min.js"></script>
  <script>
    let timer = undefined
    let timerInter = undefined
    timerInter = setInterval(() => {
      let timeout = Math.floor(Math.random() * 4 + 1)
      if (timer) return
      timer = setTimeout(() => {
        let index = Math.floor(Math.random() * 4 + 1)
        console.log(timeout, index, 'timeouttimeout');
        $('.change').removeClass('change')
        $('.test' + index).addClass('change')
        timer = undefined
      }, timeout * 1000);
    }, 2000);
  </script>
</body>

</html>

```xml
<!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>
  <style>
    .block {
      width: 400px;
      height: 300px;
      padding: 50px;
      border: 1px solid red;
      /* background: #000735; */
    }

    @keyframes twinkling {
      0% {
        opacity: 0.2;
        /* filter: alpha(opacity=20); */
        opacity: 0.2;
        transform: scale(1);
      }

      50% {
        opacity: 0.5;
        /* filter: alpha(opacity=50); */
        opacity: 0.5;
        transform: scale(1.12);
      }

      100% {
        opacity: 0.2;
        /* filter: alpha(opacity=20); */
        opacity: 0.2;
        transform: scale(1);
      }
    }


    .circle {
      width: 100px;
      height: 100px;
      border-radius: 50%;
      background: #3a96e1;
      text-align: center;
      font-weight: bold;
      position: relative;
      line-height: 100px;
      z-index: 1;
    }

    .circle::before {
      background: inherit;
      content: '';
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      z-index: -2;
      border-radius: 50%;
      animation: twinkling 2.2s ease-in-out infinite;
    }

    .circle::after {
      background: inherit;
      content: '';
      position: absolute;
      width: 110%;
      height: 110%;
      left: -5%;
      top: -5%;
      z-index: -1;
      border-radius: 50%;
      animation: twinkling 2.2s ease-in-out infinite;
    }

    .circle2 {
      margin-top: 50px;
      width: 80px;
      height: 80px;
      line-height: 80px;
      font-size: 12px;
      background: #d67c61;
    }
  </style>
</head>

<body>
  <div class="block">
    <div class="circle">千乐微云</div>
    <div class="circle circle2">小程序开发</div>
    <!-- 来源, 只做记录方便查找, 如有侵权,请联系删除。谢谢啦不是有意复制的 -->
    <!-- https://www.cnblogs.com/tianma3798/p/15335000.html -->
  </div>

</body>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值