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>display: flex;</h1>

<p>It's not <em>block</em>, <em>inline</em>, or <em>inline-block</em>... it's: FLEX!</p>

<p>the <em>relativly</em> new and wonderful layout system!</p>



<h2>flex-direction: row;</h2>

<p>Default is</p>
<pre><code>
flex-direction: row;
justify-content: flex-start; /* left */
align-items: flex-start; /* to */
</code></pre>

<section class='with-a-row'>
  <div class="box a">Box a</div>
  <div class="box b">Box b</div> 
  <div class="box c">Box c</div>
  <div class="box d">Box d</div>
</section>



<h2>flex-direction: column;</h2>

<p>Default is</p>
<pre><code>
flex-direction: column;
justify-content: flex-start; /* top */
align-items: flex-start; /* left */
</code></pre>

<section class='with-a-column'>
  <div class="box a">Box a</div>
  <div class="box b">Box b</div> 
  <div class="box c">Box c</div>
  <div class="box d">Box d</div>
</section>


<br>
<hr>

<p>Did you see how the 'justify' and 'align' direction <em>switch</em> ? depending on the flex-direction?</p>

<p>If it's direction 'row' then justify means - along the row.</p>
<p>If it's direction 'column' then justify means - along the column.</p>
<p>align is the opposite of whatever that is.</p>


              
            
!

CSS

              
                
.with-a-row {
  display: flex;
  flex-direction: row; /* (default) */
  justify-content: flex-start; /* left (default) */
}

.example {
  display: flex; /* would have all those ^ */
}


.with-a-column {
  display: flex;
  flex-direction: column;
  justify-content: stretch; /* top (default) */
  align-items: flex-start; /* left (default) */
}


/* "Row" goes from side to side on an X axis */
/* "Column" goes up and down on a Y axis */

/*
  try out:

  align-items: center;
  or
  justify-content: flex-end;
  or
  change the flex-direction

  on both of them and see what happens
*/


























/* JUST for presentation */
.box {
  padding: 6px;
  border-radius: 6px;
}
.a {
  width: 50px;
  height: 50px;
  background-color: #aadee9;
}

.b {
  width: 50px;
  height: 80px;
  background-color: #a9d9bc;
}

.c {
  width: 90px;
  height: 90px;
  background-color: #ff9197;
}

.d {
  width: 40px;
  height: 40px;
  background-color: #fbf49c;
}

section {
  border: 1px solid lightgray;
  background-color: rgba(0,0,0,.02);
}

section + section {
  margin-top: 30px;
}

h2 {
  margin-top: 60px;
}

body {
  padding: 20px;
  padding-bottom: 100px;
}

.with-a-row {
  min-height: 130px;
  /* just to give space to allow for flex-end to yield visual results */
}

.with-a-column {
  min-height: 340px;
  /* just to give space to allow for flex-end to yield visual results */
}
              
            
!

JS

              
                
              
            
!
999px

Console