Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-8 -8 64 84" shape-rendering="crispEdges">
  
  <defs>
    <pattern id="pattern" width="8" height="8" patternUnits="userSpaceOnUse" x="-4" y="-4">
      <path d="M 0 0 L8 0 8 8 0 8 z" fill="none"></path>
    </pattern>
  </defs>
    
  <g 
     class="snake-group"
     stroke-linejoin="miter" 
     stroke-linecap="square" 
     stroke-width="8"
     fill="none">
    
    <path class="dot dot-1" d="M28,48 l8,0z" />
    <path class="dot dot-2" d="M-4,48 l8,0z" />
    <path class="dot dot-3" d="M4,16 l8,0z" />
    
    <path class="snake"
          d="M0 16 h48 v16 H32 v32 H0 V48 h16 V0 H0 v16"/>
    
  </g>
  
  <rect x="-4.5" y="-4.5" width="57" height="73" fill="url(#pattern)"></rect>
</svg>
              
            
!

CSS

              
                @speed: 4s;

html { background: #8D946A; }
pattern path { stroke: #8D946A; }
.snake-group { stroke: #292A18; }

.snake { animation: stroke-anim @speed linear infinite; }
@keyframes stroke-anim {
  to { stroke-dashoffset: 0; }
}

/* Values generated from JS */
.snake {
  stroke-dasharray: 32 224;
  stroke-dashoffset: 256;
  animation-timing-function: steps(32);
}


/* ////////////////////////////////////////////////////////////////////////// */

.dot { animation: dot1 @speed steps(1) infinite; }
@keyframes dot1 { 
  0%, 26%, 91.1% { opacity: 1; }
  26.1%, 91% { opacity: 0; }
}

.dot-2 { animation-name: dot2; }
@keyframes dot2 { 
  0%, 26%, 51%, 100% { opacity: 0; }
  26.1%, 50% { opacity: 1; }
}

.dot-3 { animation-name: dot3; }
@keyframes dot3 { 
  0%, 50%, 92%, 100% { opacity: 0; }
  50.1%, 92% { opacity: 1; }
}



svg {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  margin: auto;
  max-width: 144px;
  max-height: 90vh;
}

              
            
!

JS

              
                // console.clear();

// var path = document.querySelector('.snake');
// var length = path.getTotalLength();
// var step = length/8;

// console.log(length, step);

// // Set a `stroke-dasharray` based on the length to make it look like a snake moving along the whole path.
// path.style.strokeDasharray = step + ' ' + (length - step);

// // Set the offset to length start the animation
// path.style.strokeDashoffset = length;

// // Use steps to making it "jerky"
// path.style.animationTimingFunction = 'steps(' + step + ')';
              
            
!
999px

Console