SCSS

by HikariNoSekai

HTML

<div class="select-box">
  <div class="select-box__current" tabindex="1">
    <div class="select-box__value">
      <input type="radio" class="select-box__input" id="1" value="Cream" name="Ben" checked>
      <p class="select-box__input-text">Cream</p>
    </div>
    <div class="select-box__value">
      <input type="radio" class="select-box__input" id="2" value="Cheese" name="Ben">
      <p class="select-box__input-text">Cheese</p>
    </div>
    <div class="select-box__value">
      <input type="radio" class="select-box__input" id="3" value="Milk" name="Ben">
      <p class="select-box__input-text">Milk</p>
    </div>
    <div class="select-box__value">
      <input type="radio" class="select-box__input" id="4" value="Honey" name="Ben">
      <p class="select-box__input-text">Honey</p>
    </div>
    <div class="select-box__value">
      <input type="radio" class="select-box__input" id="5" value="Toast" name="Ben">
      <p class="select-box__input-text">Toast</p>
    </div>
    <svg  x="0px" y="0px" viewBox="0 0 1000 1000" class="select-box__icon" aria-hidden="true">
<g><path d="M500,775.4L10,287.2l64.4-62.6L500,650.2l425.6-425.6l64.4,62.6L500,775.4z"/></g>
</svg>
  </div>
  <ul class="select-box__list">
    <li>
      <label for="1" class="select-box__option" aria-hidden>
        Cream
      </label>
    </li>
    <li>
      <label for="2" class="select-box__option" aria-hidden>Cheese</label>
    </li>
    <li>
      <label for="3" class="select-box__option" aria-hidden>Milk</label>
    </li>
    <li>
      <label for="4" class="select-box__option" aria-hidden>Honey</label>
    </li>
    <li>
      <label for="5" class="select-box__option" aria-hidden>Toast</label>
    </li>
  </ul>
</div>

SCSS

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  padding: 30px;
  box-sizing: border-box;
}

.select-box {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 auto;
  font-family: 'Play', 'Open Sans', 'Helvetica Neue', 'Segoe UI', 'Calibri', 'Arial', sans-serif;
  font-size: 16px;
  color: #7f858f;
  text-transform: uppercase;
  
  @media (min-width: 768px) {
    width: 70%;
  }
  
  @media (min-width: 992px) {
    width: 50%;
  }
  
  @media (min-width: 1200px) {
    width: 30%;
  }
  
  &__current {
    position: relative;
    cursor: pointer;
    outline: none;
    
    &:focus {
      & + .select-box__list {
        opacity: 1;

        // We have to set "animation-name: none;" to make the list visible (read below how it works)

        animation-name: none;
        
        .select-box__option {
          cursor: pointer;
        }
      }
      
      .select-box__icon {
        transform: translateY(-50%) rotate(180deg);
      }
    }
  }
  
  &__icon {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    width: 10px;
    fill: #7f858f;
    transition: 0.2s ease;
  }
  
  &__value {
    display: flex;
  }
  
  &__input {
    display: none;
    
    &:checked + .select-box__input-text {
      display: block;
    }
  }
  
  &__input-text {
    display: none;
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.09), inset 0 1px 3px rgba(0, 0, 0, .34);
    border-radius: 4px;
    background-color: #1d232d;
  }
  
  &__list {
    position: absolute;
    width: 100%;
    padding: 0;
    list-style: none;
    opacity: 0;
    
    // We need to use animation with delay.
    // Otherwise the click event will not have time to run on label, because this element disapears immediately when .select-box__current element loses the focus.
    // This delay will not be noticed because we set "opacity" to "0".
    // We also use "animation-fill-mode: forwards" to...