Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <!--==========================================-->
<!--Margus Lillemägi | codepen.io/VisualAngle/-->
<!--==========================================-->

<!-- This example demonstrates how to place text along various types of path and animating it with JavaScript.

Text does not have to go in a straight horizontal or vertical line. It can follow any arbitrary path; simply enclose the text in a <textPath> element that uses an xlink:href attribute to refer to a previously defined <path> element. Letters will be rotated to stand "perpendicular" to the curve.

Notice that text along a gently curving and continuous path is easier to read than text that follows a sharply angled or discontinuous path. 

Have fun with SVG! :) -->

<div id="container">
  
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMin slice" viewBox="0 0 728 400">

<!--Background-->  
<path d="M0 0h728v400H0z" fill="white"/> 


<defs>
<!--Paths-->
<path id="curvepath"
d="M 69.562364,114.36089 C 103.32827,63.71203 163.55236,65.495681 208.88203,109.8152 c 59.53014,58.20354 122.9418,2.02031 122.9418,2.02031"
stroke="red" fill="none"/>
  
<path id="round-corner"
d="m 352.12971,61.714718 h 76.26651 c 48.89538,0 76.26652,31.27814 76.26652,62.629462 v 112.62946"
stroke="red" fill="none"/>
  
<path id="sharp-corner"
d="M 250.88333,194.86796 H 423.41636 V 321"
stroke="red" fill="none"/>
  
<path id="half-circle"
d="m 55.417129,253.58589 c 19.190415,54.28031 70.516571,90.56568 128.089351,90.55363 28.71539,-0.0758 55.85531,-9.1775 78.20925,-25.02863 5.58848,-3.96278 10.87784,-8.3474 15.81791,-13.11828 4.94008,-4.77089 9.53085,-9.92804 13.72219,-15.43588 1.04784,-1.37696 2.0707,-2.77584 3.06782,-4.19608 0.49856,-0.71013 0.99068,-1.42559 1.47627,-2.14632"
stroke="red" fill="none"/>
  
<path id="diagonal"
d="M 504.30675,349.50186 671.824,102.09635"
stroke="red" fill="none"/>

</defs>

<!--Text along path-->
<use xlink:href="#curvepath"/>
<text font-size="18" font-family="monospace">
<textPath id="textOne" xlink:href="#curvepath">
text
</textPath>
</text>
  
<use xlink:href="#round-corner"/>
<text font-size="18" font-family="monospace">
<textPath id="textTwo" xlink:href="#round-corner">
text
</textPath>
</text>
  
<use xlink:href="#sharp-corner"/>
<text font-size="18" font-family="monospace">
<textPath id="textThree" xlink:href="#sharp-corner">
text
</textPath>
</text>
  
<use xlink:href="#half-circle"/>
<text font-size="18" font-family="monospace">
<textPath id="textFour" xlink:href="#half-circle">
text
</textPath>
</text>
  
<use xlink:href="#diagonal"/>
<text font-size="18" font-family="monospace">
<textPath id="textFive" xlink:href="#diagonal">
text
</textPath>
</text>

</svg>
  
</div>
              
            
!

CSS

              
                body{
  background-color:#1d1f20;
}
body, html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Demo container*/
#container{
  max-width:1200px;
  width:100%;
  overflow:hidden; 
  position: absolute;
  top: 50%;
  left: 50%;
  margin-right: -50%;
  transform: translate(-50%, -50%);
}

/* Bottom hack for IE*/
svg{
  width:100%;
  padding-bottom: 55.55%;
  height: 1px;
  overflow: visible;
 }
      

              
            
!

JS

              
                document.addEventListener('DOMContentLoaded',function(event){
  window.onload = function() { 
    
// array with text to type
  var dataText = [ "Some text typing on a path"];

  //text input caret
  var caret = "\u258B";
  
  // type a text
  // keep calling itself until the text is finished
  function type(text, i, fnCallback) {
    // chekc if text isn't finished yet
    if (i < (text.length)) {
      // add next character to text + caret
      document.querySelector("#textOne").textContent = text.substring(0, i+1) + caret;
      document.querySelector("#textTwo").textContent = text.substring(0, i+1) + caret;
      document.querySelector("#textThree").textContent = text.substring(0, i+1) + caret;
      document.querySelector("#textFour").textContent = text.substring(0, i+1) + caret;
      document.querySelector("#textFive").textContent = text.substring(0, i+1) + caret;
  

      // delay and call this function again for next character
      setTimeout(function() {
        type(text, i + 1, fnCallback)
      }, 70);
    }
    // text finished, call callback if there is a callback function
    else if (typeof fnCallback == 'function') {
      // call callback after timeout
      setTimeout(fnCallback, 1500);
    }
  }
  // start animation for a text in the dataText array
   function StartAnimation(i) {
     if (typeof dataText[i] == 'undefined'){
        setTimeout(function() {
          StartAnimation(0);
        }, 1000);
     }
     // check if dataText[i] exists
    if (i < dataText[i].length) {
      // text exists! start typewriter animation
      type(dataText[i], 0, function(){
      // after callback (and whole text has been animated), start next text
      StartAnimation(i + 1);
     });
    }
  }
  // start the text animation
  StartAnimation(0);
  }
});


              
            
!
999px

Console