<h2>Aligning a Single Flex Item on the Cross Axis: <br><code>align-self</code></h2>
  <div class="btns">
    <label for="stretch">stretch <input type="radio" name="alignitems"  value="stretch" id="stretch" checked></label>
    <label for="flex-start">flex-start <input type="radio" name="alignitems"  value="flex-start" id="flex-start"></label>
    <label for="flex-end">flex-end <input type="radio" name="alignitems"  value="flex-end" id="flex-end"></label>
    <label for="center">center <input type="radio" name="alignitems"  value="center" id="center"></label>
    <label for="baseline">baseline <input type="radio" name="alignitems"  value="baseline" id="baseline"></label>
    <div class="container">
      <div class="item">1</div>
      <div class="item large">2</div>
      <div class="item large">3</div>
      <div class="item">4</div>
      <div class="item extra">5</div>
      <div class="item">6</div>
      <div class="item">7</div>
      <div class="item large">8</div>
      <div class="item">9</div>
      <div class="item">10</div>
      <div class="item">11</div>
      <div class="item">12</div>
  <div class="dir">
    <label for="ltr">left-to-right <input type="radio" value="ltr" name="direction" id="ltr" checked></label>
    <label for="rtl">right-to-left <input type="radio" value="rtl" name="direction" id="rtl"></label>
body {
  font-family: Arial, sans-serif;
  font-size: 1.3em;
  padding: 0 2em 3em;
  line-height: 1.4;

main {
  max-width: 800px;
  margin: 0 auto;

h2 {
  margin-top: 14px;
  text-align: center;

code {
  font-family: Consolas, monospace;
  background: #ccc;
  padding: 1px 3px;

.btns {
  padding-bottom: 1em;
  text-align: center;

.dir {
  text-align: center;

label {
  margin-right: 1.3em;
  padding: 8px;

.container {
  min-height: 500px;
  border: solid 2px;
  margin-bottom: 1em;
  background: #b2d5ff;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

.ltr {
  direction: ltr;

.rtl {
  direction: rtl;

.flex-start {
  align-self: flex-start;

.flex-end {
  align-self: flex-end;

.center {
  align-self: center;

.baseline {
  align-self: baseline;

.stretch {
  align-self: stretch;

.item {
  min-width: 15%;
  background: #007ed3;
  min-height: 100px;
  border: solid 2px #305077;
  margin: 3px;
  text-align: center;
  font-size: 3em;
  color: white;
  font-weight: bold;
  line-height: 1.4;

.large {
  height: 160px;
  line-height: 3;
let btns = document.querySelector('.btns').querySelectorAll('input'),
    dirs = document.querySelector('.dir').querySelectorAll('input'),
    container = document.querySelector('.container'),
    extra = document.querySelector('.extra');

for (i of btns) {
  (function(i) {
    i.addEventListener('click', function() {
      clearClasses(extra, btns);
    }, false);

for (i of dirs) {
  (function(i) {
    i.addEventListener('click', function() {
      clearClasses(container, dirs);
    }, false);

function clearClasses (el, cl) {
  for (i of cl) {

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.