cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <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>
            
          
!
            
              .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;
}
            
          
!
999px
Loading ..................

Console