Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main class="container">
    <h1>What should I eat?</h1>
    <div id="wheel-wrap">
      <div id="wheel-border">
        <div id="wheel">
          <div class="line line-1"></div>
          <div class="line line-2"></div>
          <div class="line line-3"></div>
          <div class="line line-4"></div>
          <span class="choice" id="choice-1"></span>
          <span class="choice" id="choice-2"></span>
          <span class="choice" id="choice-3"></span>
          <span class="choice" id="choice-4"></span>
          <span class="choice" id="choice-5"></span>
          <span class="choice" id="choice-6"></span>
          <span class="choice" id="choice-7"></span>
          <span class="choice" id="choice-8"></span>
          <div id="spinner-wrap">
            <div id="spinner"></div>
            <div id="spinner-cap"></div>
          </div>
        </div>
      </div>
    </div>
    <p id="customize">Customize</p>
    <div id="form-wrap">
      <div id="close-btn">&times;</div>
      <h3>Add your own food options:</h3>
      <form>
        <label for="custom-choice-1"></label>
        <input type="text" id="custom-choice-1" placeholder="Choice #1">
        <label for="custom-choice-2"></label>
        <input type="text" id="custom-choice-2" placeholder="Choice #2">
        <label for="custom-choice-3"></label>
        <input type="text" id="custom-choice-3" placeholder="Choice #3">
        <label for="custom-choice-4"></label>
        <input type="text" id="custom-choice-4" placeholder="Choice #4">
        <label for="custom-choice-5"></label>
        <input type="text" id="custom-choice-5" placeholder="Choice #5">
        <label for="custom-choice-6"></label>
        <input type="text" id="custom-choice-6" placeholder="Choice #6">
        <label for="custom-choice-7"></label>
        <input type="text" id="custom-choice-7" placeholder="Choice #7">
        <label for="custom-choice-8"></label>
        <input type="text" id="custom-choice-8" placeholder="Choice #8">
        <button id="form-btn">Go!</button>
      </form>
    </div>
  </main>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Roboto:ital@0;1&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Rock+Salt&display=swap');

@mixin mainFlex {
  display: flex;
  justify-content: center;
  align-items: center;
}

* {
  font-family: 'Roboto', sans-serif;
  margin: 0;
  padding: 0;
}

body {
  background: darkslateblue;
}

.container {
  @include mainFlex();
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  padding: 10px 0 10px 0;
  box-sizing: border-box;
  h1 {
    font-family: 'Rock Salt', 'Roboto', sans-serif;
    font-size: 2rem;
    text-align: center;
    color: white;
    @media screen and (max-width: 767px) {
      font-size: 1.5rem;
    }
  }
  #wheel-wrap {
    @include mainFlex();
    position: relative;
    width: 550px;
    height: 550px;
    margin: 30px 0 30px 0;
    #wheel-border {
      @include mainFlex();
      position: absolute;
      width: 550px;
      height: 550px;
      border-radius: 50%;
      background: goldenrod;
      box-shadow: 0 0 30px navy;
      #wheel {
        @include mainFlex();
        width: 500px;
        height: 500px;
        border-radius: 50%;
        border: 2px solid white;
        background: linear-gradient(#c33764, #1d2671);
        overflow: hidden;
        position: relative;
        .line {
          position: absolute;
          width: 505px;
          height: 2px;
          background: white;
        }
        .line-2 {
          transform: rotate(45deg);
        }
        .line-3 {
          transform: rotate(-45deg);
        }
        .line-4 {
          transform: rotate(90deg);
        }
        .choice {
          @include mainFlex();
          justify-content: flex-start;
          position: absolute;
          font-size: 1.5rem;
          font-style: italic;
          text-transform: capitalize;
          text-decoration: none;
          color: white;
          width: 180px;
          height: 40px;
          text-shadow: 
            5px 25px 0 orangered,
            5px -25px 0 limegreen;
        }
        #choice-1 {
          left: 20px;
          top: 172px;
          transform: rotate(22.5deg);
        }
        #choice-2 {
          left: 102px;
          top: 90px;
          transform: rotate(67.5deg);
        }
        #choice-3 {
          right: 101px;
          top: 90px;
          transform: rotate(112.5deg);
        }
        #choice-4 {
          right: 20px;
          top: 172px;
          transform: rotate(157.5deg);
        }
        #choice-5 {
          right: 20px;
          bottom: 171px;
          transform: rotate(202.5deg);
        }
        #choice-6 {
          right: 101px;
          bottom: 90px;
          transform: rotate(247.5deg);
        }
        #choice-7 {
          left: 102px;
          bottom: 90px;
          transform: rotate(292.5deg);
        }
        #choice-8 {
          left: 20px;
          bottom: 171px;
          transform: rotate(337.5deg);
        }
        #spinner-wrap {
          @include mainFlex();
          filter: drop-shadow(0 0 3px navy);
          #spinner {
            width: 450px;
            height: 50px;
            background: orangered;
            clip-path: polygon(90% 0%, 100% 50%, 90% 100%, 0% 100%, 10% 50%, 0% 0%);
            &:hover {
              cursor: pointer;
            }
          }
          #spinner-cap {
            position: absolute;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: goldenrod;
            box-shadow: 0 0 5px navy;
          }
        }
      }
    }
    @media screen and (max-width: 767px) {
      transform: scale(0.6);
      margin-top: 0;
    }
    @media screen and (max-height: 799px) {
      transform: scale(0.8);
    }
    @media screen and (max-width: 320px) {
      transform: scale(0.5);
      margin-top: 0;
    }
  }
  #customize {
    margin-top: 30px;
    color: white;
    text-decoration: underline;
    opacity: 0.5;
    &:hover {
      cursor: pointer;
    }
  }
  #form-wrap {
    position: absolute;
    width: 700px;
    height: auto;
    background: mediumslateblue;
    border-radius: 20px;
    box-shadow: 0 0 18px rgba(0,0,0,0.3);
    margin: 20px;
    padding: 10px 10px 30px 10px;
    box-sizing: border-box;
    display: none;
    #close-btn {
      position: absolute;
      font-size: 3rem;
      color: white;
      top: 0;
      right: 15px;
      &:hover {
        cursor: pointer;
      }
    }
    h3 {
      color: white;
      text-align: center;
      margin: 50px 0 30px 0;
    }
    form {
      @include mainFlex();
      flex-direction: column;
      width: 90%;
      margin: auto;
      input {
        width: 90%;
        height: 35px;
        margin-bottom: 20px;
        padding: 0 10px 0 10px;
        box-sizing: border-box;
        border-radius: 5px;
        border: none;
      }
      button {
        font-size: 1rem;
        color: darkslateblue;
        margin: 15px 0 50px 0;
        width: 150px;
        height: 35px;
        background: limegreen;
        border-radius: 5px;
        border: none;
        &:hover {
          cursor: pointer;
        }
      }
    }
    @media screen and (max-width: 767px) {
      width: 90%;
      top: 0;
    }
  }
}
              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', () => {

  const spinner = document.getElementById('spinner');
  const customize = document.getElementById('customize');
  const formWrap = document.getElementById('form-wrap');
  const closeBtn = document.getElementById('close-btn');
  const formBtn = document.getElementById('form-btn');

  const choice1 = document.getElementById('choice-1'),
        choice2 = document.getElementById('choice-2'),
        choice3 = document.getElementById('choice-3'),
        choice4 = document.getElementById('choice-4'),
        choice5 = document.getElementById('choice-5'),
        choice6 = document.getElementById('choice-6'),
        choice7 = document.getElementById('choice-7'),
        choice8 = document.getElementById('choice-8');

  const custom1 = document.getElementById('custom-choice-1'),
        custom2 = document.getElementById('custom-choice-2'),
        custom3 = document.getElementById('custom-choice-3'),
        custom4 = document.getElementById('custom-choice-4'),
        custom5 = document.getElementById('custom-choice-5'),
        custom6 = document.getElementById('custom-choice-6'),
        custom7 = document.getElementById('custom-choice-7'),
        custom8 = document.getElementById('custom-choice-8');

  const options = [
    'Tacos', 'Burgers', 'Steak', 'Ramen',
    'Salad', 'Pizza', 'Sushi', 'BBQ'
  ];

  const addOptions = () => {
    choice1.textContent = options[0];
    choice2.textContent = options[1];
    choice3.textContent = options[2];
    choice4.textContent = options[3];
    choice5.textContent = options[4];
    choice6.textContent = options[5];
    choice7.textContent = options[6];
    choice8.textContent = options[7];
  }
  
  addOptions();

  const changeOptions = () => {
    custom1.value === '' ? 
      choice1.textContent = options[0] :
      choice1.textContent = custom1.value;
    custom2.value === '' ?
      choice2.textContent = options[1] :  
      choice2.textContent = custom2.value;
    custom3.value === '' ?
      choice3.textContent = options[2] :
      choice3.textContent = custom3.value;
    custom4.value === '' ?
      choice4.textContent = options[3] :
      choice4.textContent = custom4.value;
    custom5.value === '' ?
      choice5.textContent = options[4] :
      choice5.textContent = custom5.value;
    custom6.value === '' ?
      choice6.textContent = options[5] :  
      choice6.textContent = custom6.value;
    custom7.value === '' ?
      choice7.textContent = options[6] :
      choice7.textContent = custom7.value;
    custom8.value === '' ?
      choice8.textContent = options[7] :
      choice8.textContent = custom8.value;
  }

  let deg = 0;
  let speed = 1;
  let interval;

  const changeSpeed = () => {
    speed += 0.01;
  }

  const spin = () => {
    clearInterval(interval);
    spinner.style.transform = `rotate(${deg}deg)`;
    deg++;
    changeSpeed();
    interval = setInterval(spin, speed);
  }

  spinner.addEventListener('click', () => {
    const randomTime = Math.ceil(Math.random() * 10000);
    speed = 1;
    requestAnimationFrame(spin);
    setTimeout(() => {
      clearInterval(interval);
    }, randomTime);
  });

  customize.addEventListener('click', () => {
    formWrap.style.display = 'block';
    customize.style.filter = 'blur(5px)';
  });

  closeBtn.addEventListener('click', () => {
    formWrap.style.display = 'none';
    customize.style.filter = 'blur(0)';
  });

  formBtn.addEventListener('click', (e) => {
    e.preventDefault();
    changeOptions();
    formWrap.style.display = 'none';
    customize.style.filter = 'blur(0)';
  });

});
              
            
!
999px

Console