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

              
                <h1>Flexbox examples</h1>
<h2>Example 1</h2>
<p>No flex attributes are set for any items. Defaults flex values are applied: <code>flex: 1 1 auto;</code></p>
<figure id="example-1">
  <div>
    <h2>Item one</h2>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur egestas est in pharetra dapibus. Aenean condimentum justo in ligula feugiat cursus. Donec ultrices libero id mi tincidunt elementum. Nunc tempor lorem vel eros eleifend placerat. Sed id nulla magna. 
    </p>
  </div>

  <div>
    <h2>Item two</h2>
    <p>Mauris pharetra nulla augue, et euismod elit iaculis quis. Donec laoreet elementum lectus sed rhoncus. </p>
  </div>

  <div>
    <h2>Item three</h2>
    <p>Vestibulum risus sem, aliquam sit amet odio in, vestibulum malesuada urna. Curabitur vulputate molestie ex et pellentesque. Suspendisse convallis nisi id arcu volutpat, sit amet hendrerit libero tristique. Quisque rhoncus sodales augue, sit amet malesuada nisl auctor at.</p>
  </div>
</figure>

<h2>Example 2</h2>
<p>All flex items are set to: <code>flex: 1 1 600px;</code></p>
<figure id="example-2">
  <div>
    <h2>Item one</h2>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur egestas est in pharetra dapibus. Aenean condimentum justo in ligula feugiat cursus. Donec ultrices libero id mi tincidunt elementum. Nunc tempor lorem vel eros eleifend placerat. Sed id nulla magna. 
    </p>
  </div>

  <div>
    <h2>Item two</h2>
    <p>Mauris pharetra nulla augue, et euismod elit iaculis quis. Donec laoreet elementum lectus sed rhoncus. </p>
  </div>

  <div>
    <h2>Item three</h2>
    <p>Vestibulum risus sem, aliquam sit amet odio in, vestibulum malesuada urna. Curabitur vulputate molestie ex et pellentesque. Suspendisse convallis nisi id arcu volutpat, sit amet hendrerit libero tristique. Quisque rhoncus sodales augue, sit amet malesuada nisl auctor at.</p>
  </div>
</figure>
<h2>Example 3</h2>
<p>The first flex item has fixed width: <code>flex: 1 0 400px;</code> All other items have default values.</p>
<figure id="example-3">
  <div>
    <h2>Item one</h2>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur egestas est in pharetra dapibus. Aenean condimentum justo in ligula feugiat cursus. Donec ultrices libero id mi tincidunt elementum. Nunc tempor lorem vel eros eleifend placerat. Sed id nulla magna. 
    </p>
  </div>

  <div>
    <h2>Item two</h2>
    <p>Mauris pharetra nulla augue, et euismod elit iaculis quis. Donec laoreet elementum lectus sed rhoncus. </p>
  </div>

  <div>
    <h2>Item three</h2>
    <p>Vestibulum risus sem, aliquam sit amet odio in, vestibulum malesuada urna. Curabitur vulputate molestie ex et pellentesque. Suspendisse convallis nisi id arcu volutpat, sit amet hendrerit libero tristique. Quisque rhoncus sodales augue, sit amet malesuada nisl auctor at.</p>
  </div>
  <div>
    <h2>Item four</h2>
    <p>Fusce pretium, nibh non porttitor blandit, nisi turpis auctor risus, at mattis dui orci nec nisi. Ut nec mi ligula. Aliquam eu tempus lectus, eget condimentum felis.</p>
  </div>
</figure>
              
            
!

CSS

              
                html{
  background: #333;
  color: #FFF;
}
body{
  margin: 0 auto;
  width: 90%;
}
figure {
  display: flex; 
  font-size: .9em; 
}
figure div {
  background: #ccc;
  color: #222;
  margin: 1em;
  padding: 0 1em;
  border: solid 1px #FFF;
}
#example-2 > div{
  flex: 1 1 600px;
}
#example-3 > div:first-child{
  flex: 1 0 400px;
}
              
            
!

JS

              
                
              
            
!
999px

Console