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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Stagger Spacing</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">
    </head>
    <body>
         <div id="background">
              <!-- the dynamic html would be what is in the span -->
              <!-- user could determine the spacing using the data-spacing attribute -->
               <span id="mainLegals" data-spacing="4">
                   <p>If you don't start, you can't finish</p>
                   <p>If you don't start, you can't finish</p>
                   <p>If you don't start, you can't finish</p>
                   <p>If you don't start, you can't finish</p>
                   <p>If you don't start, you can't finish</p>
                   <p>If you don't start, you can't finish</p>
                   <p>If you don't start, you can't finish</p>
                   
               </span>
         </div>
    </body>
</html>
              
            
!

CSS

              
                body, html {
  margin: 0; padding: 0;
}
p { 
  line-height: 0.1em; 
  font-family: 'arial' 
}
#background {
  position: absolute;
  background-image: url('http://assets.neunie.com/files/tuts/2019/01/30/diagonal.png');
  width: 504px;
  height:380px;
}
              
            
!

JS

              
                function spacingStagger() {
    var mainLegals = document.getElementById("mainLegals");
    var breaks = document.querySelectorAll("#mainLegals p");
    var spacing = mainLegals.dataset.spacing;
    var spaceCounter = parseInt(spacing);

    var spaceWidth = 2; // set the space size to 2px as default
    var baseline = 28; // first line starts from baseline, this could have mad editable from the html too
    var spacer = spaceCounter * spaceWidth;

    if (spacing == 0) {
        console.log("do not stagger the copy");
    } else {

        //if spacing is set to anything other than 0, calculate the values
        for (i = 0; i < breaks.length; i++) {
            breaks[i].style.paddingLeft = baseline + "px";
            baseline = baseline + spacer;
        };
    }
}
//call this function after the page elements have been added
spacingStagger(); 
              
            
!
999px

Console