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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <h1>
Lightweight JavaScript for equal-height boxes
</h1>
<p>
  If the (faux) CSS-based solutions don't work for you because you need to position content at the bottom of the boxes you can use this script-based solution. It's written in vanilla JavaScript, works in IE8 and does not require jQuery.
</p>
<div class="boxes">
  <div>
    Curabitur blandit tempus porttitor. Nullam quis risus eget urna mollis ornare vel eu leo. Nulla vitae elit libero, a pharetra augue. Nulla vitae elit libero, a pharetra augue.
  </div>
  <div>
    Maecenas sed diam eget risus varius blandit sit amet non magna. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
  </div>
  <div>
    Pellentesque ornare sem lacinia quam venenatis vestibulum.
  </div>
  <div>
    Aenean eu leo quamornare sem lacinia quam venenatis vestibulum.
  </div>
  <div>
    Lacinia quam venenatis vestibulum sed diam eget risus varius blandit sit amet non magna.
  </div>
  <div>
    Curabitur blandit tempus porttitor. Sed posuere consectetur est at lobortis. Aenean lacinia bibendum nulla sed consectetur.
  </div>
  <div>
    Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
  </div>
</div>
              
            
!

CSS

              
                
.boxes > * {
  width: 200px;
  float: left;
  padding: 12px;
  margin: 6px;
  background: #707f8e;
  box-sizing: border-box;
  color: #fff;
}



/* page styles */

body {
  background: #34495e;
  color: #707f8e;
  font: 18px/1.2 sans-serif;
}

h1 {
  font: lighter 2em sans-serif;
}
              
            
!

JS

              
                function equalize(sel) {

  var els = Array.prototype.slice.call(document.querySelectorAll(sel));  
  var row = [];
  var max;
  var top;
  
  function setHeights() {
    row.forEach(function(e) {
      e.style.height = max + 'px';
    });
  }

  for (var i=0; i < els.length; i++) {
    var el = els[i];
    el.style.height = 'auto';
    if (el.offsetTop !== top) {
      // new row detected
      setHeights();
      top = el.offsetTop;      
      max = 0;
      row = [];
    }
    row.push(el);
    max = Math.max(max, el.offsetHeight);
  }
  setHeights(); // last row
}

// you might want to use addEventListener instead!
window.onload = window.onresize = function() {
  equalize('.boxes > *');
};

              
            
!
999px

Console