cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <div class="wrapper">
  <code class="code"></code>
  <div class="example">
    <p>0123456789</p>
    <p>1/2 15/17</p>
    <p>My fine flowers</p>
  </div>

</div>

<div class="hidden">
  <label class="control">
      <input 
        type="checkbox"
        class="control__input"
        name="{{ name }}"
      >
      <span
        class="control__toggler">
      </span>
      <span
        class="control__text">{{ name }}
      </span>
    </label>
</div>
            
          
!
            
              @font-face {
  font-family: VotoSerif;
  font-display: swap;
  src: url(https://yoksel.github.io/variable-fonts/assets/fonts/VotoSerif/VotoSerifGX.ttf) format("truetype");
}

HTML, BODY {
  display: flex;
  min-height: 100%;
  width: 100%;
}

BODY {
  display: flex;
  justify-content: center;
  align-items: center;
  font: 16px/1.4 Trebuchet MS, Arial, sans-serif;
}

P {
  margin-top: 0;
  margin-bottom: .4em;
}

.hidden {
  display: none;
}

.wrapper {
  width: 700px;
  margin: 0 32px;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
}

.code {
  width: 100%;
  margin-bottom: 32px;
  padding: 8px;
  border-radius: 5px;
  background: #ECECEC;
}

.example {
  flex-basis: 50%;
  flex-grow: 1;
  font-family: VotoSerif;
  font-size: 65px;  
  line-height: 1;
  font-variation-settings: "wght" 20, "wdth" 100;
}

.controls {
  margin-left: 16px;
  padding: 16px;
  box-sizing: border-box;
  flex-basis: 150px;
  border: 1px solid #DDD;
  border-radius: 5px;
}

.control {
  position: relative;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  
  &:last-child {
    margin-bottom: 0;
  }
  
  &__input {
    visibility: hidden;
    position: absolute;
  }
  
  &__toggler {
    width: 48px;
    height: 32px;
    display: flex;
    align-items: center;
    background: #FFF;
    border-radius: 32px;
    box-shadow: 0 0 0 1px;
    color: #CCC;
    cursor: pointer;
    transition: all .25s;
    
    &::before {
      content: '';
      display: block;
      width: 24px;
      height: 24px;
      margin: 0 3px;
      background: currentColor;
      border-radius: 50%;
    }
  }
  
  &__input:checked + &__toggler {
    justify-content: flex-end;
    color: darkturquoise;
  }
  
  &__text {
    margin-left: 12px;
  }
} 
            
          
!
            
              const config = {
  propName: 'font-feature-settings',
  features: {
    liga: true,
    smcp: false,
    frac: false,
    onum: false,
    zero: false
  }
};

const wrapper = document.querySelector('.wrapper');
const example = document.querySelector('.example');
const code = document.querySelector('.code');
const template = document.querySelector('.control').outerHTML;

const controls = document.createElement('div');
controls.classList.add('controls');
let inputs;
const state = {};

fillControls();
wrapper.appendChild(controls);
addControlsActions();
setFeatures();

function fillControls() {
  const featuresKeys = Object.keys(config.features);
  
  featuresKeys.forEach(feature => {
    const view = {
      name: feature
    };
    
    const output = Mustache.render(template, view);
    controls.innerHTML += output;  
    state[feature.name] = feature.value;
  });
}

function addControlsActions() {
  inputs = controls.querySelectorAll('.control__input');
  inputs.map = [].map;
  
  inputs.forEach(input => {
    input.checked = config.features[input.name];
    
    input.addEventListener('change', function() {
      config.features[this.name] = !config.features[this.name];
      setFeatures();
    });
  });
}

function setFeatures() {
  const featuresKeys = Object.keys(config.features);
  
  const features = featuresKeys.map(key => {
    return `"${key}" ${config.features[key] ? 'on' : 'off'}`;
  });
  const style = features.join(', ');
  
  code.innerHTML = `${config.propName}: ${style};`;
  example.style[config.propName] = style;
}
            
          
!
999px
Loading ..................

Console