Is it possible to make a squiggly line?

前端 未结 12 1669
无人及你
无人及你 2021-02-01 19:04

If I wanted to make a horizontal line, I would do this:




        
12条回答
  •  温柔的废话
    2021-02-01 19:29

    Here is a SASS wave line generator based on the answer from @yeerk. If you want triangles, use the generator above by @lilliputten.

    $waveHeight: 40px;
    $waveLength: 70px;
    $waveRadius: 13px; // adjust depending on length
    $waveThickness: 8px;
    
    @mixin waveSide() {
      position: absolute;
      background: radial-gradient(ellipse, transparent, transparent $waveRadius, black $waveRadius, black #{$waveRadius + $waveThickness}, transparent #{$waveRadius + $waveThickness});
      background-size: #{$waveLength} #{$waveHeight * 2};
      height: $waveHeight;
    }
    
    .wavy {
      width: 400px; // give the wave element a length here
    
      @include waveSide;
    
      &::before {
        $waveOffset: $waveLength / 2;
        @include waveSide;
    
        content: '';
        width: calc(100% - #{$waveOffset});
        top: $waveHeight;
        left: $waveOffset;
        background-position: 0px -#{$waveHeight};
      }
    }
    

提交回复
热议问题