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

              
                <div class="cont">
  <h1>Flexbox Align & Justify Examples
  <br>flex-direction: column</h1>

  <h2>Initial values:</h2>
  <ul>
    <li>align-items: stretch</li>
    <li>justify-content: flex-start</li>
  </ul>

  <p>The width of the flex items defaults to auto, as these are block level elements they stretch to the full width of their parent. So the flex-container is full width and align-items stretch means the items stretch to meet it.</p>
</div>
<div class="code">
  <div class="wrapper example1">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>

<div class="cont">
  <h2>Changing the height of the container</h2>

  <p>I have given the flex container a height of 25em. As justify-content is flex-start the items display at the start of the flex container.</p>
</div>
<div class="code">
  <div class="wrapper example2">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>
<div class="cont">
  <h2>align-items: flex-start</h2>
  <p>The items align to the start of the flex container.</p>
</div>
<div class="code">
  <div class="wrapper example3">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>

<div class="cont">
  <h2>align-items: flex-end</h2>
  <p>The items align to the end of the flex container.</p>
</div>
<div class="code">
  <div class="wrapper example4">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>

<div class="cont">
  <h2>justify-content: space-between</h2>
  <p>Spacing items out evenly and flush with top and bottom of the container. Youwill only get space between elements if the container is taller than the sum of the items (if you have added a height).</p>
</div>
<div class="code">
  <div class="wrapper example7">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>

<div class="cont">
  <h2>justify-content: space-around</h2>
  <p>Spacing items out evenly with space all around.</p>
</div>
<div class="code">
  <div class="wrapper example8">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>

<div class="cont">
  <h2>justify-content: flex-end</h2>
  <p>Justifying to the end of the flex container.</p>
</div>
<div class="code">
  <div class="wrapper example9">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>

<div class="cont">
  <h2>justify-content: center</h2>
  <p>Justifying to the center of the flex container.</p>
</div>
<div class="code">
  <div class="wrapper example10">
    <div>One
      <br>... is taller
      <br>than the rest.</div>
    <div>Two</div>
    <div>Three</div>
    <div>Four</div>
    <div>Five</div>
    <div>Six</div>
  </div>
</div>


</div>
              
            
!

CSS

              
                .example2 {
  height: 25em;
}

.example3 {
  height: 25em;
  align-items: flex-start;
}

.example4 {
  height: 25em;
  align-items: flex-end;
}

.example5 {
  height: 25em;
  align-items: center;
}

.example6 {
  height: 25em;
  align-items: baseline;
}

.example6 div:first-child {
  font-size: 150%;
}

.example7 {
  height: 30em;
  justify-content: space-between;
}

.example8 {
  height: 30em;
  justify-content: space-around;
}

.example9 {
  height: 30em;
  justify-content: flex-end;
}

.example10 {
  height: 30em;
  justify-content: center;
}


.wrapper {
  width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background-color: #fafafa;
}

.wrapper div {
  padding: 10px;
  background-color: rgb(41,73,130);
  color: #fff;
  border-radius: 5px;
}

html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}

body {
  font: 1em/1.4 Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: #fafafa;
  color: #000;
  margin:0;
}

.cont {
  width: 800px;
  margin: 0 auto;
}

.code {
  background-color: #333;
  padding: 20px;
}
              
            
!

JS

              
                
              
            
!
999px

Console