css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <main class="u-centralise u-txt-center">
<h1>Which was the best moment in Game 7 of the 2016 NBA Finals?</h1>
<form action="#" method="POST" class="u-pos-relative">
  <div class="l-flex-parent c-4options u-margin-bot" id="js-options">
  <label class="l-flex-1_4 o-option js-option">
    <input class="o-option__input" type="radio" name="moment" value="block">
    <img src="https://www.chenhuijing.com/ott-radio-btns/img/block_200.jpg" srcset="https://www.chenhuijing.com/ott-radio-btns/img/block_400.jpg 2x" alt="The Block" class="o-option__img">
    <span class="o-option__txt">The Block</span>
  </label>
 
  <label class="l-flex-1_4 o-option js-option">
    <input class="o-option__input" type="radio" name="moment" value="shot" class="o-option__img">
     <img src="https://www.chenhuijing.com/ott-radio-btns/img/shot_200.jpg" srcset="https://www.chenhuijing.com/ott-radio-btns/img/shot_400.jpg 2x" alt="The Shot" class="o-option__img">
    <span class="o-option__txt">The Shot</span>
  </label>

  <label class="l-flex-1_4 o-option js-option">
    <input class="o-option__input" type="radio" name="moment" value="stop">
    <img src="https://www.chenhuijing.com/ott-radio-btns/img/stop_200.jpg" srcset="https://www.chenhuijing.com/ott-radio-btns/img/stop_400.jpg 2x" alt="The Stop" class="o-option__img">
    <span class="o-option__txt">The Stop</span>
  </label>

  <label class="l-flex-1_4 o-option js-option">
    <input class="o-option__input" type="radio" name="moment" value="feelz">
    <img src="https://www.chenhuijing.com/ott-radio-btns/img/feels_200.jpg" srcset="https://www.chenhuijing.com/ott-radio-btns/img/feels_400.jpg 2x" alt="The Feelz" class="o-option__img">
    <span class="o-option__txt">The Feelz</span>
  </label>
  </div>
  <div class="l-flex-parent u-flex-end c-actions" id="js-actions">
    <div class="l-flex-1_4 c-logo">
      <img class="c-logo__img" src="https://www.chenhuijing.com/ott-radio-btns/img/nba-trophy_200.jpg" srcset="https://www.chenhuijing.com/ott-radio-btns/img/nba-trophy_400.jpg 2x" alt="Larry O'Brien trophy">
    </div>
    <div class="l-flex-1_4">
      <button class="o-btn c-action js-btn" type="reset">Cancel</button>
    </div>
    <div class="l-flex-1_4">
      <button class="o-btn c-action js-btn">OK</button>
    </div>
  </div>
</form>
</main>
            
          
!
            
              @import 'https://fonts.googleapis.com/css?family=Shrikhand|Yantramanav';

html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

main {
  padding: 1em;
  font-family: 'Yantramanav', sans-serif;
  max-width: 65em;
}

h1 {
  font-family: 'Shrikhand', cursive;
  font-size: calc(2.25vw + 1em);
  line-height: 1.2;
  margin-bottom: 0.5em;
}

.l-flex-parent {
  display: flex;
}

.l-flex-1_4 {
  flex: 0 0 25%;
}

.o-option {
  cursor: pointer;
}

.o-option__img {
  width: 20vw;
  height: 20vw;
  max-height: 200px;
  max-width: 200px;
  margin-bottom: 1em;
  border-radius: 50%;
  border: 4px solid #FDBB30;
}

.o-option__input {
  opacity: 0;
  position: absolute;
  
  &:checked + .o-option__img {
    border-color: #860038;
  }
  
  &:checked ~ .o-option__txt {
    color: #860038;
  }
}

.o-option__txt {
  font-size: calc(1em + 1.1vw);
  display: block;
}

.o-btn {
  width: 20vw;
  height: 20vw;
  max-height: 200px;
  max-width: 200px;
  font-size: calc(1em + 1.1vw);
  font-family: inherit;
  border-radius: 50%;
  border: 0;
  background-color: #860038;
  color: #FDBB30;
  cursor: pointer;
  outline: 0;
  
  &:hover {
    background-color: #FDBB30;
    color: #860038;
  }
}

.c-logo {
  transform: translateX(-100%);
}

.c-logo__img {
  width: 20vw;
  height: 20vw;
  max-height: 200px;
  max-width: 200px;
  border-radius: 50%;
  opacity: 0;
}

.has-animation {
  .c-actions {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: -1;
  }
  
  .o-option,
  .c-action,
  .c-logo__img {
    transition: transform 0.4s ease-in-out, opacity 0.4s ease-out;
    transition-delay: .1s;
  }
  
  .c-action,
  .c-logo__img,
  .is-active .o-option:not(.is-checked) {
    transform: scale(0);
    opacity: 0;
    z-index: 0;
  }

  .is-active.c-actions {
    z-index: 1;
  }

  .is-active .c-action,
  .is-active .c-logo__img {
    opacity: 1;
    transform: scale(1);
  }

  .is-active.c-4options {
    z-index: -1;
    .is-checked.o-option:nth-child(1) {
      transform: translateX(100%);
    }
    .is-checked.o-option:nth-child(3) {
      transform: translateX(-100%);
    }
    .is-checked.o-option:nth-child(4) {
      transform: translateX(-200%);
    }
  }
}

.u-flex-end {
  justify-content: flex-end;
}

.u-txt-center {
  text-align: center;
}

.u-centralise {
  margin-left: auto;
  margin-right: auto;
}

.u-pos-relative {
  position: relative;
}

.u-margin-bot {
  margin-bottom: 2em;
}
            
          
!
            
              const doc = window.document.documentElement
const optWrapper = document.getElementById('js-options')
const actWrapper = document.getElementById('js-actions')
const optInput = doc.querySelectorAll('.js-option')
const btn = doc.querySelectorAll('.js-btn')

if ( window.Modernizr.csstransforms3d && window.requestAnimationFrame ) {
  doc.className += ' has-animation'
  window['hasAnimation'] = true
}

const addEventListenerList = (list, event, fn) => {
  for (var i = 0, len = list.length; i < len; i++) {
    list[i].addEventListener(event, fn, false);
  }
}

const removeClass = (list, className, fn) => {
  for (var i = 0, len = list.length; i < len; i++) {
    list[i].classList.remove(className);
  }
}

const handleClick = (element) => {
  const target = element.target
  const parent = target.parentNode
  if(target.checked) {
    parent.classList.add('is-checked')
  optWrapper.classList.add('is-active')
  actWrapper.classList.add('is-active')
  }
}

const handleAction = (element) => {
  optWrapper.classList.remove('is-active')
  actWrapper.classList.remove('is-active')
  removeClass(optInput, 'is-checked')
}

addEventListenerList(optInput, 'change', handleClick)

addEventListenerList(btn, 'click', handleAction)
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console