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 class="desc">using percentages</h1>
<div id="main-page-percent" class="container">
  <section class="content-area"><h1>Main Content</h1><p>9 columns</p><p class="width"></p></section>
  <section class="nav-area"><h1>Navigation</h1><p>4 columns</p><p class="width"></p></section>
  <section class="extra-links"><h1>Extras</h1><p>3 columns</p><p class="width"></p></section>
</div>
<h1 class="desc">using flex ordinals</h1>
<div id="main-page-flex" class="container">
  <section class="content-area"><h1>Main Content</h1><p>9 columns</p><p class="width"></p></section>
  <section class="nav-area"><h1>Navigation</h1><p>4 columns</p><p class="width"></p></section>
  <section class="extra-links"><h1>Extras</h1><p>3 columns</p><p class="width"></p></section>
</div>
<h1 class="desc">alternative: adding left &amp; right padding to child elements</h1>
<div id="main-page-flex-alt" class="container">
  <section class="content-area"><h1>Main Content</h1><p>9 columns</p><p class="width"></p></section>
  <section class="nav-area"><h1>Navigation</h1><p>4 columns</p><p class="width"></p></section>
  <section class="extra-links"><h1>Extras</h1><p>3 columns</p><p class="width"></p></section>
</div>
              
            
!

CSS

              
                @import "compass/css3";

// Using the Flexbox tricks from CSS Tricks
// https://css-tricks.com/using-flexbox/

@mixin flex-display () {
  display: -webkit-box;  // OLD - iOS 6-, Safari
  display: -moz-box;     // OLD - Firefox 19-
  display: -ms-flexbox;  // TWEENER - IE 10
  display: -webkit-flex; // NEW - Chrome prefixed
  display: flex;         // NEW - Proper Spec
}

@mixin flex-order ( $ordinal ) {
  -webkit-box-ordinal-group: $ordinal; // OLD - iOS 6-, Safari 3.1-6
  -moz-box-ordinal-group: $ordinal;    // OLD - Firefox 19-
  -ms-flex-order: $ordinal;            // TWEENER - IE 10
  -webkit-order: $ordinal;             // NEW - Chrome prefixed
  order: $ordinal;                     // NEW - Proper Spec
}

@mixin flex-size ( $ordinal, $fallback ) {
  -webkit-box-flex: $ordinal; // OLD - iOS 6-, Safari 3.1-6
  -moz-box-flex: $ordinal;    // OLD - Firefox 19-
  width: $fallback;           // OLD - Fallback to prevent collapse
  -webkit-flex: $ordinal;     // NEW - Chrome prefixed
  -ms-flex: $ordinal;         // NEW - IE prefixed
  flex: $ordinal;             // NEW - Proper Spec
}

// Add the Dosis font
@import url(https://fonts.googleapis.com/css?family=Dosis:200,300,400,500,600,700,800);

// I like simple math
* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

html {
  background-color: white;
  font-size: 62.5%;
  font-family: Dosis;
  font-weight: 500;
}

.container {
  @include flex-display();
  max-width: 960px;
  margin: 0 auto;
  font-size: 1.6rem;
  line-height: 2rem;
  .content-area {
    @include flex-order(2);
    padding: 1rem;
    background-color: rgba(red, 0.3);
  }
  .nav-area {
    @include flex-order(1);
    padding: 1rem;
    background-color: rgba(green, 0.3);
  }
  .extra-links {
    @include flex-order(3);
    padding: 1rem;
    background-color: rgba(blue, 0.3);
  }
  h1 {
    font-size: 2rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 1rem;
  }
}

#main-page-percent {
  .content-area {
    width: 56.25%;
  }
  .nav-area {
    width: 25%
  }
  .extra-links {
    width: 18.75%;
  }
}

#main-page-flex {
  .content-area {
    @include flex-size(9, 56.25%);
  }
  
  .nav-area {
    @include flex-size(4, 25%);
  }
  
  .extra-links {
    @include flex-size(3, 18.75%);
  }
}

#main-page-flex-alt {
  .content-area {
    @include flex-size(9, 56.25%);
    padding: 1rem 0;
  }
  
  .nav-area {
    @include flex-size(4, 25%);
    padding: 1rem 0;
  }
  
  .extra-links {
    @include flex-size(3, 18.75%);
    padding: 1rem 0;
  }
  .content-area > *, .nav-area > *, .extra-links > * {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

h1.desc {
  max-width: 960px;
  margin: 2rem auto 0.5rem;
  padding: 0 1rem;
  font-size: 2rem;
  font-weight: 200;
  color: tint(black, 70%);
}
              
            
!

JS

              
                function fillText(containerId, columnClass) {
  var conWidth = $(containerId).outerWidth();
  var colWidth = $(containerId + " " + columnClass).outerWidth();
  $(containerId + " " + columnClass + " .width").html(colWidth + " pixels<br/>" + (colWidth/conWidth*100).toFixed(2) + "%");
}

function updateWidths() {
  fillText('#main-page-percent', '.content-area');
  fillText('#main-page-percent', '.nav-area');
  fillText('#main-page-percent', '.extra-links');
  fillText('#main-page-flex', '.content-area');
  fillText('#main-page-flex', '.nav-area');
  fillText('#main-page-flex', '.extra-links');
  fillText('#main-page-flex-alt', '.content-area');
  fillText('#main-page-flex-alt', '.nav-area');
  fillText('#main-page-flex-alt', '.extra-links');
}
setInterval(updateWidths, 100);
updateWidths();
              
            
!
999px

Console