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

              
                <div class='container'>
  <form class='blur-40' id='form'>
    <div class='field'>
      <label for='function'>Function</label>
      <select name='function' id='function' data-amt='10px'>
        <option value='none'>None</option>
        <option value='blur' selected>Blur</option>
        <option value='brightness'>Brightness</option>
        <option value='contrast'>Contrast</option>
        <option value='grayscale'>Grayscale</option>
        <option value='hue-rotate'>Hue-rotate</option>
        <option value='invert'>Invert</option>
        <option value='opacity'>Opacity</option>
        <option value='saturate'>Saturate</option>
        <option value='sepia'>Sepia</option>   
      </select>
    </div>
    <div class='field'>
      <label for='value' id='value_label'>Value</label>
      <input id='value' type='range' name='value' min='0' max='100' value='40' />
    </div>
    <div class='field'>
      <p id='info'>
      </p>
    </div>
  </form>
</div>
              
            
!

CSS

              
                .container {
  background: url(https://images.unsplash.com/photo-1514888286974-6c03e2ca1dba?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1454&q=80) no-repeat center center;
  background-size: cover;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  form {
    border-radius: 4px;
    width: 50%;
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    justify-content: center;
    .field {
      margin: 1em;
      display: flex;
      flex-flow: column nowrap;
      align-items: center;
      justify-content: center;
      text-align: center;
    }
  }
}

@function grayscale($value) {
  @return #{ "grayscale(" + $value + "%)" };
}

@function invert($value) {
  @return #{ "invert(" + $value + ")" };
}

@function opacity($value) {
  @return #{ "opacity(" + $value + "%)"};
}

@function saturate($value) {
  @return #{ "saturate(" + $value  + ")"};
}

@for $i from 1 through 100 {
  .blur-#{$i} {
    backdrop-filter: blur(#{$i}px);
  }
  .brightness-#{$i} {
    backdrop-filter: brightness(calc(calc(#{$i} * .01) * 2));
  }
  .contrast-#{$i} {
    backdrop-filter: contrast(calc(calc(#{$i} * .01) * 2));
  }
  .grayscale-#{$i} {
    backdrop-filter: grayscale(#{$i});
  }
  .hue-rotate-#{$i} {
    backdrop-filter: hue-rotate(#{$i}deg);
  }
  .invert-#{$i} {
    backdrop-filter: invert(calc(calc(#{$i} * .1) * 2));
  }
  .opacity-#{$i} {
    background-color: white;
    backdrop-filter: opacity(#{$i});
  }
  .saturate-#{$i} {
    backdrop-filter: saturate(#{$i});
  }
  .sepia-#{$i} {
    backdrop-filter: sepia(#{$i});
  }
}


              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', () => {
  const selectTrigger = document.getElementById('function');
  const valueTrigger = document.getElementById('value');
  const container = document.getElementById('form');
  const infoBox = document.getElementById('info');
  const vLabel = document.getElementById('value_label');
  selectTrigger.onchange= update;
  valueTrigger.onchange = update;
  update();
  
  function update() {
    var value = valueTrigger.value;
    var select = selectTrigger.value;
    var classes = container.classList.value;
    var newClass = select + '-' + value;
    if (classes.length > 0) {
      container.classList.remove(classes);
    }
    container.classList.add(newClass);
    var infoText = "";
    var valueText = "";
    switch(select) {
      case "blur":
        infoText = "The Blur function applies a gaussian blur to the filter. The parameter passed is the radius. It must be a defined length, such as ch, em, ex, rem, vh, vw, vmin, vmax, or px.";
        valueText = value + "px";
        break;
      case "brightness":
        infoText = "The Brightness function makes the filter brighter or darker. The parameter passed is the amount to change, as a number or percentage.";
        valueText = (value * .01) * 2;
        break;
      case "contrast":
        infoText = "The contrast function changes the filter contrast. The parameter passed is the result, as a number or percentage.";
        valueText = (value * .01) * 2;
        break;
      case "grayscale":
        infoText = "The grayscale function converts the filter to grayscale. The parameter passed is the amount of the conversion, as a number or a percentage."
        valueText = value + "%";
        break;
      case "hue-rotate":
        infoText = "The Hue-Rotate function changes the overall hue of the filter. The parameter passed is the relative change in hue of the sample, as an angle. Acceptable units are deg, grad, rad, and turn.";
        valueText = value + "deg";
        break;
      case "invert":
        infoText = "The invert function inverts the color samples. The passed parameter is the amount, as a number or percentage.";
        valueText = (value * .1) * 2;
        break;
      case "opacity":
        infoText = "The opacity function applies transparency to the sample. The passed paremeter is the amount, as a number or percentage.";
        valueText = value + "%";
        break;
      case "saturate":
        infoText = "The saturate function super saturates or desaturates the sample. The passed parameter is the amount of the conversion, as a number or percentage.";
        valueText = value;
        break;
      case "sepia":
        infoText = "The sepia function applies a sepia tone to the sample. The passed parameter is the amount of the conversion, as a number or percentage";
        valueText = value;
        break;
    }
    infoBox.innerText = infoText;
    vLabel.innerText = valueText;
  }
})
              
            
!
999px

Console