Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <div class="demo">
  <div class="demo__canvas">
    <div class="demo__wrapper">
      <div id="box-to-model" contenteditable><span>The quick brown fox jumped over the lazy dog, which woke the lazy dog from his slumber, so Watson barked and the fox apologized in whichever way foxes say things.</span></div>
    </div>
  </div>
  <div class="demo__controls">
    <div class="demo__group-container">
      <div class="group">
        <label for="font-family">
          <span class="label">font-family:</span>
          <select id="font-family">
            <option value="'Times New Roman', serif">Times New Roman</option>
            <option value="Futura, Verdana, sans-serif">Futura, Verdana</option>
            <option value="Baskerville, Georgia, sans-serif">Baskerville, Georgia</option>
            <option value="Arial, Helvetica, sans-serif">Arial, Helvetica</option>
            <option value="'Courier New', Courier, monospace">Courier New, Courier</option>
          </select>
        </label>

        <label for="color">
          <span class="label">color:</span>
          <select id="color">
            <option value="black">black</option>
            <option value="white">white</option>
            <option value="var(--cyan)">cyan</option>
            <option value="var(--purple)">purple</option>
            <option value="var(--pink)">pink</option>
            <option value="var(--red)">red</option>
          </select>
        </label>
        
        <label for="font-weight">
          <span class="label">font-weight:</span>
          <select id="font-weight">
            <option value="normal">normal</option>
            <option value="bold">bold</option>
          </select>
        </label>

        <label for="font-style">
          <span class="label">font-style:</span>
          <select id="font-style">
            <option value="normal">normal</option>
            <option value="italic">italic</option>
          </select>
        </label>
      </div>

      <div class="group">
        <label for="line-height">
          <span class="label">line-height:</span>
          <select id="line-height">
            <option value="12px">12px</option>
            <option value="16px">16px</option>
            <option value="24px" selected>24px</option>
            <option value="32px">32px</option>
            <option value="64px">64px</option>
          </select>
        </label>

        <label for="font-size">
          <span class="label">font-size:</span>
          <select id="font-size">
            <option value="12px">12px</option>
            <option value="16px" selected>16px</option>
            <option value="24px">24px</option>
            <option value="32px">32px</option>
            <option value="48px">48px</option>
            <option value="64px">64px</option>
          </select>
        </label>
        
        <label for="text-align">
          <span class="label">text-align:</span>
          <select id="text-align">
            <option value="left">left</option>
            <option value="center">center</option>
            <option value="right">right</option>
            <option value="justify">justify</option>
          </select>
        </label>
        
        <label for="text-decoration">
          <span class="label">text-decoration:</span>
          <select id="text-decoration">
            <option value="none">none</option>
            <option value="underline">underline</option>
            <option value="overline">overline</option>
            <option value="line-through">line-through</option>
          </select>
        </label>
      </div>

      <div class="group">
        <label for="word-spacing">
          <span class="label">word-spacing:</span>
          <select id="word-spacing">
            <option value="-8px">-8px</option>
            <option value="-4px">-4px</option>
            <option value="-2px">-2px</option>
            <option value="0" selected>0</option>
            <option value="2px">2px</option>
            <option value="4px">4px</option>
            <option value="8px">8px</option>
          </select>
        </label>

        <label for="letter-spacing">
          <span class="label">letter-spacing:</span>
          <select id="letter-spacing">
            <option value="-8px">-8px</option>
            <option value="-4px">-4px</option>
            <option value="-2px">-2px</option>
            <option value="0" selected>0</option>
            <option value="2px">2px</option>
            <option value="4px">4px</option>
            <option value="8px">8px</option>
          </select>
        </label>

        <label for="text-shadow">
          <span class="label">text-shadow:</span>
          <select id="text-shadow">
            <option value="none">none</option>
            <option value="0 0 2px var(--cyan)">0 0 2px cyan</option>
            <option value="0 0 4px var(--purple)">0 0 4px purple</option>
            <option value="0 0 8px var(--pink)">0 0 8px pink</option>
            <option value="0 0 16px var(--red)">0 0 16px red</option>
          </select>
        </label>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap');

html {
  --background: hsla(180, 100%, 0%, 1);
  --text-color: hsla(180, 100%, 90%, .75);
  --purple: hsla(240, 90%, 60%, 1);
  --background2: hsla(240, 75%, 90%, .75);
  --color2: hsla(240, 80%, 10%, 1);
  --pink: hsla(300, 90%, 60%, 1);
  --background3: hsla(300, 75%, 90%, .75);
  --color3: hsla(300, 80%, 10%, 1);
  --red: hsla(0, 90%, 60%, 1);
  --background4: hsla(0, 75%, 90%, .75);
  --color4: hsla(0, 80%, 10%, 1);
  --cyan: hsla(180, 90%, 60%, 1);
  --background5: hsla(180, 75%, 90%, .75);
  --color5: hsla(180, 80%, 10%, 1);
}

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

body {
  background: var(--background);
  color: #fff;
  font-family: 'Open Sans', sans-serif;
}

.demo {
  display: grid;
  grid-template-columns: 100vw;
  grid-template-rows: 80vh 1fr;
  overflow: hidden;
}

@media (min-width: 800px) {
  .demo {
    grid-template-columns: calc(100vw - 320px) 320px;
    grid-template-rows: auto;
  }
}

@media (min-width: 1200px) {
    .demo {
      grid-template-columns: calc(100vw - 640px) 640px;
  }
}

select {
  font-family: 'Open Sans', sans-serif;
}

.demo__canvas {
  background: var(--color5);
  height: 80vh;
  text-align: center;
  padding: 20px;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

@media (min-width: 800px) {
  .demo__canvas {
    height: 100vh;
  }
}

.demo__wrapper {
  background: hsla(0, 0%, 50%, .5);
  border-radius: 5px;
}

#box-to-model {
  color: #000;
  background: #fff;
  margin: 10px;
  padding: 10px;
}

.demo__controls {
  background: var(--background);
  box-sizing: border-box;
  height: 100vh;
  overflow: visible;
  position: relative;
  transition: transform 250ms ease-out;
}

.demo__group-container {
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
  justify-content: center;
  overflow: auto;
  margin: 10px 0;
  padding: 0 10px 10px;
  height: calc(100vh - 20px);
}

.group {
  background: #fff;
  color: #333;
  border-radius: 10px 0 10px 0;
  padding: 10px 20px;
  margin: 0 10px 20px;
  min-width: 200px;
  max-width: 100%;
  flex-grow: 1;
  flex-basis: 200px;
  mix-blend-mode: hard-light;
  max-width: 300px;
}

.group:nth-child(1) {
  --group-dark: var(--color2);
  --group-light: var(--background2);
  background: var(--group-light);
}

.group:nth-child(2) {
  --group-dark: var(--color3);
  --group-light: var(--background3);
  background: var(--group-light);
}
.group:nth-child(3) {
  --group-dark: var(--color4);
  --group-light: var(--background4);
  background: var(--group-light);
}
.group:nth-child(4) {
  --group-dark: var(--color5);
  --group-light: var(--background5);
  background: var(--group-light);
}

.label {
  display: block;
  padding-bottom: 8px;
  color: white;
  pointer-events: none;
}

label:hover .label,
label:focus .label {
   mix-blend-mode: soft-light;
}

label {
  display: block;
  font-size: 18px;
  line-height: 24px;
  margin-bottom: 20px;
  position: relative;
}

select {
  box-sizing: border-box;
  border-radius: 5px 0 5px 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 24px;
  border: 0;
  border-top: 1px solid var(--group-dark);
  border-left: 1px solid var(--group-dark);
  padding: 8px 32px 8px 8px;
  width: 100%;
  -webkit-appearance: none;
  -moz-appearance: none;
  mix-blend-mode: multiply;
  transition: transform 100ms ease-out;
  box-shadow: 0px 2px 1px 1px var(--group-dark);
}

select:hover,
select:focus{
  transform: scale(1.05);
  mix-blend-mode: overlay;
  box-shadow: 0px 2px 2px 2px var(--group-dark);
}

label::after {
  content: '';
  position: absolute;
  font-size: 18px;
  line-height: 24px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--group-dark); 
  right: 10px;
  bottom: 15px;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* Demo Specific Overrides */
#box-to-model span {
  transition: all 750ms ease-out;
}
.demo__canvas {
  background: var(--color2);
}
.demo__wrapper {
  max-width: 90%;
  width: 450px;
}
              
            
!

JS

              
                // set our box and controls as globals
const box = document.getElementById('box-to-model');
const controls = [...document.querySelectorAll('select')];
const demoContainer = document.querySelector('.demo__wrapper');
const controlsContainer = document.querySelector('.demo__controls');

init();

// bind our change events and set initial properties
function init() {
  controls.map(bindChangeEvents);
  updateProperties();
}

// set updateProperties to run when a control changes
function bindChangeEvents(control) {
  control.addEventListener('change', updateProperties);
}

// when a property changes, set the box's style with a string
function updateProperties() {
  box.style = controls.reduce(stringifyProperties, "");
}

// convert properties and values from controls to a single string
function stringifyProperties(string, control) {
  const declaration = `${control.id}: ${control.value};`;
  return `${string} ${declaration}`;
}
              
            
!
999px

Console