css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1><code>display: flex</code> vs <code>display: inline-flex</code></h1>
<subtitle>What's the difference?</subtitle>

<h2>Example 1: <code>display: flex</code></h2>
<p>Three containers <span class="flex-color">in this color</span> with <code>display: flex</code>, containing three child divs <span class="inline-color">in this color</span> with <code>flex: 1</code>.</p>
<p>Each <span class="flex-color">parent container</span> sits on its own line. The <span class="inline-color">three children</span> occupy an equal width.</p>
<div class="container--flex">
  <div class="flex-child"></div>
  <div class="flex-child"></div>
  <div class="flex-child"></div>
</div>
<div class="container--flex">
  <div class="flex-child"></div>
  <div class="flex-child"></div>
  <div class="flex-child"></div>
</div>
<div class="container--flex">
  <div class="flex-child"></div>
  <div class="flex-child"></div>
  <div class="flex-child"></div>
</div>

<h2>Example 2: <code>display: inline-flex</code></h2>
<p>Three containers <span class="flex-color">in this color</span> with <code>display: inline-flex</code>, containing three child divs <span class="inline-color">in this color</span> with <code>flex: 1</code> and <code>min-width: 50px</code>.</p>
<p>Each <span class="flex-color">parent container</span> sits next to the other one, since they can all fit on the same row. The width of the <span class="flex-color">parent container</span> is dependent on the size of <span class="inline-color">the children</span>, which here have been given a min-width of 50px.</p>
<div class="container--inline-flex">
  <div class="flex-child"></div>
  <div class="flex-child"></div>
  <div class="flex-child"></div>
</div>
<div class="container--inline-flex">
  <div class="flex-child"></div>
  <div class="flex-child"></div>
  <div class="flex-child"></div>
</div>
<div class="container--inline-flex">
  <div class="flex-child"></div>
  <div class="flex-child"></div>
  <div class="flex-child"></div>
</div>

<h2>Explanation</h2>
<p>An element with <code>display: flex</code> is similar to an element with <code>display: block</code>, whereby it occupies the whole row. However, its child elements can be positioned flexibly and dynamically, compared to previously-available layout properties.</p>
<p>If we change this to <code>display: inline-flex</code>, it:
  <ul>
    <li>makes the parent container display inline</li>
    <li>still applies all flex properties to the children, no differently form <code>display: flex</code></li>
  </ul>
  This means that if the child elements aren't too big, two containers with <code>display: inline-flex</code> can sit side-by-side.
</p>
<p>Other display properties also have an inline counterpart:</p> 
<ul><li><code>block</code> has <code>inline-block</code></li>
  <li><code>table</code> has <code>inline-table</code></li>
  <li>and even <code>grid</code> has <code>inline-grid</code></li>
  <p><a href="https://www.w3.org/TR/css-flexbox-1/#flex-containers">Read more about the flex display property in the W3 spec.</a></p>
            
          
!
            
              $flexColor: #64B5F6;
$inlineColor: #F06292;

.container--inline-flex,
.container--flex {
  background-color: $flexColor;
  margin-bottom: 10px; /* just for aesthetics */
}
.container--flex {
  display: flex;
}
.container--inline-flex {
  display: inline-flex;
}
.flex-child {
  flex: 1;
  min-width: 50px;
  min-height: 50px;
  margin: 10px;
  background-color: $inlineColor;
}

.flex-color {
  color: $flexColor;
}
.inline-color {
  color: $inlineColor;
}

/* Remaining styles are just to make the demo look nice */
body {
  font-family: 'Open Sans', sans-serif;
}
code {
  background-color: #EEEEEE;
  padding: 1px 5px;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console