tabs flexbox css only

by marusti

HTML

<section>

  <input id="tab-one" type="radio" name="grp" checked="checked" />
  <label for="tab-one">Tab One</label>
  <div class="tab-content">
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
    sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
    Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
  </div>

  <input id="tab-two" type="radio" name="grp" />
  <label for="tab-two">Tab Two</label>
  <div class="tab-content">
    <img src="https://sbarthel.github.io/images/img/berg.JPG" alt="mountain" />
  </div>

  <input id="tab-three" type="radio" name="grp" />
  <label for="tab-three">Tab Three</label>
  <div class="tab-content">
    ... no fixed height for tabbed area!
  </div>

</section>

CSS

section {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

label {
  flex: 1;
  background: #eee;
  border: 1px solid #ddd;
  padding: .7em 1em;
  cursor: pointer;
  z-index: 1;
  margin-left: -1px;
}

label:first-of-type {
  margin-left: 0;
}

.tab-content {
  width: 100%;
  margin-top: -1px;
  padding: 1em;
  border: 1px solid #ddd;
  -webkit-order: 1;
  order: 1;
}

input[type=radio],
.tab-content {
  display: none;
}

input[type=radio]:checked + label {
  background: #fff;
  border-bottom: 1px solid #fff;
}

input[type=radio]:checked + label + .tab-content {
  display: block;
}