css doodle

177 阅读1分钟

绘制css图案的web组件

css-doodle.com/

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>css-doodle</title>
    <style>
      :root {
        --customUnit: 100%;
        --bgColor: #0a0c27;
      }
      @supports (display: flex) {
        html,
        body {
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
      html,
      body {
        width: var(--customUnit);
        height: var(--customUnit);
        background: var(--bgColor);
    </style>
    <script src="https://unpkg.com/css-doodle@0.15.3/css-doodle.min.js"></script>
  </head>
  <body>
    <css-doodle> 
      :doodle{ 
        @grid : 10 x 1 / 61.8vmax; 
      } 
      @place-cell:center;
      @size:calc(@index()*10%);
      border-width: calc(@index()*1vmin);
      border-radius: 50%;
      border-style: dashed;
      border-color: hsla(calc(20*@index()),70%,68%,calc(4/@index()*.8));
       --d:@rand(20s,40s);
      --rf:@rand(360deg);
      --rt:calc(var(--rf) + @pick(1turn,-1turn));
      animation: spin var(--d) linear infinite; 
      @keyframes spin {
        from{
          transform: rotate(var(--rf))
        }
        to{
          transform: rotate(var(--rt))
        }
      }
  </css-doodle>
  </body>
</html>