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.

            
              <section class="section__1">
    <h1>Yes, this is that presentation</h1>
    <p>It's about flexbox</p>
</section>

<section class="section__1">
  <h1>S1: flex-direction: row (default)</h1>
  <div class="flex ">
    <div class="item">s1 item 1</div>
    <div class="item">s1 item 2</div>
    <div class="item">s1 Some more txt in this item</div>
    <div class="item">s1 item 4</div>
  </div>
  <p>items will display as a row and line up at the start of that axis. <br>still space at the end of the flex container.</p>
</section>

<section class="section__1-b">
  <h1>S1-b: flex-direction: row but with more text</h1>
  <div class="flex ">
    <div class="item">s1 item 1</div>
    <div class="item">s1 item 2</div>
    <div class="item">This behavior is likely to be familiar to you if you have ever used Flexbox, but perhaps you have wondered how the browser is working that sizing out, as if you look in multiple modern browsers you will see that they all do the same thing</div>
  </div>
  <p>more text to these items so they will fill the container</p>
</section>



<section class="section__1-c">
  <h1>S1-c: 
    flex-grow:1 / flex-basis: auto
  </h1>
  <div class="flex">
    <div class="item">Wouldn't</div>
    <div class="item">we</div>
    <div class="item">better start farming potatoes ?</div>
  </div>
  <p>short version: flex: 1 1 auto  ==> default</p>
</section>


<section class="section__1-c">
  <h1>S1-c with more text: 
    flex-grow:0 / flex-basis: auto
  </h1>
  <div class="flex">
    <div class="item">Wouldn't</div>
    <div class="item">we</div>
    <div class="item">This behavior is likely to be familiar to you if you have ever used Flexbox, but perhaps you have wondered how the browser </div>
  </div>
  <p>No space to distribute here</p>
</section>


<section class="section__1-d">
  <h1>S1-d: Flex-basis: 0</h1>
  <div class="flex ">
    <div class="item">Wouldn't</div>
    <div class="item">we</div>
    <div class="item">This behavior is likely to be familiar to you if you have ever used Flexbox, but perhaps you have wondered how the browser </div>
  </div>
  <p>short version: flex: 1 1 0; <br>flex-basis to 0 and flex-grow to 1 <br> all of our boxes: no starting width <br>so space in  flex container is shared out evenly</p>
</section>
<hr>

<section class="section__2">
  <h1>S2 : flex-direction: column;</h1>
  <div class="flex flex-col">
    <div class="item">s2 item 1</div>
    <div class="item">s2 item 2</div>
    <div class="item">This behavior is likely to be familiar to you if you have ever used Flexbox, but perhaps you have wondered how the browser is working that sizing out, as if you look in multiple modern browsers you will see that they all do the same thing. </div>
  </div>
</section>

<section class="section__3">
  <h1>S3: flex-direction: row-reverse</h1>
  <div class="flex flex-row-reverse">
    <div class="item flex-grow">s3 item 1</div>
    <div class="item flex-grow">s3 item 2</div>
    <div class="item flex-grow">s3 item 3</div>
  </div>
  <p>Reverse the order of items in a row direction</p>
</section>


<section class="section__4">
  <h1>S4: flex-direction: col-reverse</h1>
  <div class="flex flex-col-reverse">
    <div class="item flex-grow">s4 item 1</div>
    <div class="item flex-grow">s4 item 2</div>
    <div class="item flex-grow">s4 item 3</div>
  </div>
  <p>Reverse the order of items in a column direction</p>
</section>

<hr>


<section class="section__5">
  <h1>S5 Flex-wrap but no grow</h1>
  <div  class="flex flex-wrap">
    <div class="item">Orange potato</div>
    <div class="item">Sprout tomato pea</div>
    <div class="item">Gumbo beet</div>
    <div class="item">greens corn soko</div>
    <div class="item">endive gumbo gourd.</div>
    <div class="item">Parsley shallot courgette tatsoi pea</div>
  </div>
  <p>Makes the items (flex-grow: 0) wrap to the next row</p>
</section>

<section class="section__5">
  <h1>S5 Flex-wrap with growing items</h1>
  <div  class="flex flex-wrap">
    <div class="item flex-grow">Orange potato</div>
    <div class="item flex-grow">Sprout tomato pea</div>
    <div class="item flex-grow">Gumbo beet</div>
    <div class="item flex-grow">greens corn soko</div>
    <div class="item flex-grow">endive gumbo gourd.</div>
    <div class="item flex-grow">Parsley shallot courgette tatsoi pea</div>
  </div>
  <p>Makes the items (flex-grow: 1) wrap to the next row</p>
</section>

<hr>

<section class="section__6">
  <h1>S6 Ordering items</h1>
  <div  class="flex">
    <div class="item">first item</div>
    <div class="item">second item</div>
    <div class="item">third item</div>
    <div class="item">fourth item</div>
    <div class="item">last item</div>
  </div>
  <p>Order in the flexbox container !!</p>
</section>

<hr>

<section class="section__7">
  <h1>S7 Justification: center</h1>
  <div  class="flex">
    <div class="item">first item - some more content</div>
    <div class="item">second item</div>
    <div class="item">third item</div>
    <div class="item">fourth item</div>
    <div class="item">last item</div>
  </div>
  <p>Justify: center</p>
</section>


<section class="section__7b">
  <h1>S7b Justification: space-between</h1>
  <div  class="flex justify-between">
    <div class="item">first item - some more content</div>
    <div class="item">second item</div>
    <div class="item">third item</div>
    <div class="item">fourth item</div>
    <div class="item">last item</div>
  </div>
  <p>Justify: spread the available space "between" the items</p>
</section>


<section class="section__7c">
  <h1>S7c Justification: space-around</h1>
  <div  class="flex justify-around">
    <div class="item">first item - some more content</div>
    <div class="item">second item</div>
    <div class="item">third item</div>
    <div class="item">fourth item</div>
    <div class="item">last item</div>
  </div>
  <p>Justify: spread the available space "around" the items</p>
</section>



<section class="section__8">
  <h1>S8 Practical example</h1>
  <div class="nav-wrapper border border-dashed border-blue-400 flex flex-col-reverse md:flex-col">
  <nav class="meta flex flex-col sm:flex-row justify-between items-center">
    <div class="search p-2 flex">
      Search
      <input class="searchBox-query form-control ml-4 px-4 border border-solid border-grey-500" name="query" placeholder="Zoeken" type="search">
    </div>
    <div class="languages">
      <ul class="flex flex-row">
        <li><a class="p-2" href="">Nederlands</a></li>
        <li><a class="p-2" href="">Frans</a></li>
        <li><a class="p-2" href="">Engels</a></li>
      </ul>
    </div>
  </nav>
  <header class="header flex flex-col sm:flex-row justify-between items-center bg-white p-2 sm:p4"><a href="/" class="flex items-center text-gray-800 active--exact active"><span class="font-bold hidden sm:inline-block sm:visible">Site Home</span></a><nav class="nav flex flex-col sm:flex-row"><a href="/works" class="nav__link uppercase text-black text-sm font-medium p-2 hover:text-red-600">Works</a><a href="/about" class="nav__link uppercase text-black text-sm font-medium p-2 hover:text-red-600">About</a><a href="/blog" class="nav__link uppercase text-black text-sm font-medium p-2 hover:text-red-600">Blog</a><a href="/wp" class="nav__link uppercase text-black text-sm font-medium p-2 hover:text-red-600">WP</a><a href="/kitchen-sink" class="nav__link uppercase text-black text-sm font-medium p-2 hover:text-red-600">Sink</a><a href="/contact" class="nav__link uppercase text-black text-sm font-medium p-2 hover:text-red-600">Contact</a></nav></header>
  </div>
  <p>Meta nav is on top, except on mobile where the meta nav is on the bottom. <br>Via flex-column-reverse on the parent container.</p>
</section>


<section class="section__9">
  <h1>S9 Center center</h1>
  <div  class="flex justify-center items-center" style="height: 300px">
    <div class="item">first item - some more content</div>
  </div>
  <p>justify-content: center + align-items: center</p>
</section>

<section class="section__9b">
  <h1>S9b Center center (align-items)</h1>
  <div  class="flex justify-center items-center" style="height: 300px">
    <div class="item">first item - some more content</div>
    <div class="item">second item</div>
  </div>
  <p>justify-content: center + align-items: center <br>aligns the items inside a flex container along the cross axis just like justify-content does along the main axis.</p>
</section>
            
          
!
            
              :root {
  --main-bg-color: rgba(255,0,0,.15);
  --div-bg-color: rgba(0,0,0,1);
}
section {
  height: 100vh;
  border: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  > div {
    border: 2px solid var(--div-bg-color);
    // padding: 1rem;
  }
}
.item {
  background: var(--main-bg-color);
  border: 2px solid ;
  padding: .5rem
}

.section__1-c {
  .item {
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: auto;
  }
}

.section__1-d {
  .item {
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0;
  }
}
.section__6 {
  .item:nth-of-type(1) { order: 3; }
  .item:nth-of-type(2) { order: 4; }
  .item:nth-of-type(3) { order: 1; }
  .item:nth-of-type(4) { order: 5; }
  .item:nth-of-type(5) { order: 2; }
  .item:last-child {
    order: -1;
  }
}
.section__7 {
  > div {
    justify-content: center;
    .item {
      // flex-grow: 1;
    }
  }
}




// codepen
body {
  width: 70vw;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  // flex-direction: column-reverse;
}

h1, p { 
  text-align: center; 
  color: #777; 
  margin: 1em 0;
}
h1 {
  font-size: 1.6em;
  color: black;
}
            
          
!
            
              // https://www.smashingmagazine.com/2018/09/flexbox-sizing-flexible-box/

// https://yoksel.github.io/flex-cheatsheet/
            
          
!
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.

Console