CSS only accordion

https://codepen.io/raubaca/pen/PZzpVe?editors=1100

by Destan Sarpkaya

HTML

<div class="tabs">
  <div class="tab">
    <input type="checkbox" id="chck1">
    <label class="tab-label" for="chck1">Item 1</label>
    <div class="tab-content">
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Ipsum, reiciendis!
    </div>
  </div>
  <div class="tab">
    <input type="checkbox" id="chck2">
    <label class="tab-label" for="chck2">Item 2</label>
    <div class="tab-content">
      Lorem ipsum dolor sit amet consectetur adipisicing elit. A, in!
    </div>
  </div>
</div>

SCSS

body {
  font-family: sans-serif;
}

$bgColor: #fafafa;
$textColor: #555;

input {
  position: absolute;
  opacity: 0;
  z-index: -1;
}


.row {
  display: flex;
  .col {
    flex: 1;
    &:last-child {
      margin-left: 1em;
    }
  }
}


.tabs {
  overflow: hidden;
}
.tab {
  width: 100%;
  color: $textColor;
  overflow: hidden;
  &-label {
    display: flex;
    justify-content: space-between;
    padding: 1em;
    background: $bgColor;
    cursor: pointer;
    
    &:hover {
      background: darken($bgColor, 10%);
    }
    &::after {
      content: "⌄";
      width: 1em;
      height: 1em;
      text-align: center;
      transition: all 0.35s;
    }
  }
  &-content {
    max-height: 0;
    padding: 0 1em;
    color: $textColor;
    background: $bgColor;
    transition: all 0.35s;
  }
  &-close {
    display: flex;
    justify-content: flex-end;
    padding: 1em;
    font-size: 0.75em;
    background: $bgColor;
    cursor: pointer;
    &:hover {
      background: darken($bgColor, 10%);
    }
  }
}

input:checked {
  + .tab-label {
    background: darken($bgColor, 10%);
    &::after {
      transform: rotate(90deg);
    }
  }
  ~ .tab-content {
    max-height: 100vh;
    padding: 1em;
  }
}