CSS 实现炫酷的动态背景效果

活不多说,直接开始
效果图:
CSS 实现炫酷的动态背景效果_第1张图片
HTML:
一个万能的div

    <div class="bgc">div>

主要是css部分
使用background属性

  1. 纯色
  2. 线性渐变(linear-gradient)
  3. 径向渐变(radial-gradient)
  4. 角向渐变(conic-gradient)
  5. 多重线性渐变(repeating-linear-gradient)
  6. 多重径向渐变(repeating-radial-gradient)
  7. 多重角向渐变(repeating-conic-gradient)

实现以上效果需要使用repeating-conic-gradient多重角向渐变

      .bgc {
     
        background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.8deg);
        width: 500px;
        height: 300px;
      }

这里的角度小于1deg时,效果最佳

为了更加炫酷,为其加上动画

      @keyframes change {
     
        0% {
     
        }
        20% {
     
          background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.7deg);
        }
        40% {
     
          background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.6deg);
        }
        60% {
     
          background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.5deg);
        }
        80% {
     
          background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.4deg);
        }
        100% {
     
          background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.4deg);
        }
      }
      .bgc {
     
        background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.8deg);
        width: 500px;
        height: 300px;
        animation: change 2s linear infinite;
      }

你可能感兴趣的:(css,css3,css,animation,html,js)