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

              
                <h1>Ask us a question</h1>
<textarea id="question" style="width:100%; height:8em;"></textarea>
<input type="submit">

<div id="answers" class="flex-layout">
  <h2>Where's the $59 million loan coming from? What's the interest rate?</h2>
  <h2>How long will the Bond last?</h2>
  <h2>Has the previous bond from 1989 been satisfied?</h2>
  <h2>With bigger buildings and new facilities, will the library's operating costs increase?</h2>
  <h2>When will we see our property taxes increase because of the library's bond referendum?</h2>
  <h2>Are there any book purchases earmarked for the bond funds?</h2>
  <h2>How are you going to fill the libraries you build if none of the money is going to books?</h2>
</div>
              
            
!

CSS

              
                * {
  margin: 0;
  box-sizing: border-box;
}

.flex-layout {
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-flow: row wrap;
  -ms-flex-flow: row wrap;
  flex-flow: row wrap;
}

.flex-layout > * {
  -ms-flex: auto;
  -webkit-flex: auto;
  flex: auto;
  width: 20em;
}

body,
h2 {
  padding: 10px;
}

body {
  font-family: Helvetica;
}

#answers:first-child {
  background-color: seashell;
}
              
            
!

JS

              
                  var question = document.getElementById('question');
        var faqs = document.querySelectorAll('#answers h2');
        
        question.oninput = function(){
            var q = this.value;
            for(var i=0; i<faqs.length; i++){
                faqs[i].style.order = Math.floor(1000 * (1.0 - faqs[i].innerHTML.distance(q)));
            }
        }
              
            
!
999px

Console