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 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

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

              
                <main>
  <h1>Fuentes variables y accesibilidad</h1>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati aliquam rerum reiciendis maiores esse sapiente sint reprehenderit modi aperiam, ducimus dolore fugiat dolor unde minima repellat, placeat, dolorum sed alias.</p>
  <p>Assumenda, enim ipsam? Est possimus cumque ut quas ullam nemo, perspiciatis iure modi doloribus autem fuga, repellendus beatae a excepturi omnis optio vero et, totam recusandae eum. Atque, perspiciatis ipsa?</p>
  <p>Qui exercitationem quia saepe optio minus, ducimus quidem corrupti debitis facere praesentium dignissimos. Voluptatibus, officiis maiores at sint aperiam alias quae molestias eveniet nam, dolorum enim! Doloremque iure quae rem!</p>
  <p>Deleniti ut corrupti eos ratione harum ipsam vero cupiditate praesentium. Fugiat perspiciatis excepturi deleniti iusto, blanditiis, ipsum inventore molestias ad, sed quas in ut voluptates dolorum distinctio assumenda deserunt beatae.</p>
</main>
<div class="controls">
  <button class="js-config config"><svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><title>cog</title><g fill=""><path d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"></path></g></svg></button>
  <ul class="variable-axis">
    <li><label for="">Body weight</label><input type="range" data-axis="bodyWght" min="400" max="700" value="400"></li>
    <li><label for="">Body width</label><input type="range" data-axis="bodyWdth" min="75" max="100" value="100"></li>
    <li><label for="">Title weight</label><input type="range" data-axis="titleWght" min="400" max="700" value="700"></li>
    <li><label for="">Title width</label><input type="range" data-axis="titleWdth" min="75" max="100" value="75"></li>
  </ul>
  <div class="feedback">Well done! Now you can reload the page, your text preferences are safe with us.</div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Cabin:wdth,wght@75..100,400..700&display=swap');

:root{
   --bodyWdth: 100;
   --bodyWght: 400;
   --titleWdth: 75;
   --titleWght: 700;
}

body{
  font-family: 'Cabin', sans-serif;
  font-size: 1.25em;
  font-weight: var(--bodyWght);
  font-stretch: calc(1% * var(--bodyWdth));
}

main{
  width: 90%; 
  max-width: 40rem;
  margin: 10vh auto 0;
}

h1{
  font-stretch: calc(1% * var(--titleWdth));
  font-weight: var(--titleWght);
}

.controls{
  position: fixed;
  bottom: 4vw;
  right: 4vw;
}

.config{
  background-color: transparent;
  border: none;
  background-color: #000;
  padding: 1em;
  border-radius: 50%;
  line-height: 1;
  cursor: pointer;
  
  
  &.opened-controls{
    background-color: #ff4a4a;
  }
  
  svg{
    fill: #fff;
    width: 1.5em;
    height: 1.5em;
  }
}

.variable-axis{
  position: absolute;
  right: 0;
  bottom: 100%;
  list-style: none;
  background: #fff;
  padding: 1.5em;
  box-shadow: 0 0 .75em rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease-out ;
}

input{
  display: block;
  margin: .5em 0 1.5em;
}

.opened-controls + .variable-axis{  
  opacity: 1;
  pointer-events: all;
}

.feedback{
  position: fixed;
  left: 50%;
  transform: translate(-50%, 1em);
  font-size: 1rem;
  line-height: 1.5;
  bottom: 2vw;
  background-color: #000;
  padding: 1em;
  box-shadow: 0 .125em .5em rgba(0,0,0, .3);
  color: #fff;
  border-radius: .25em;
  text-align: center;
  opacity: 0; 
  transition: opacity .3s ease-out, transform .3s ease-out;
  
  &.is--visible{
    opacity: 1; 
    transform: translate(-50%, 0);
  }
}
              
            
!

JS

              
                const ranges = document.querySelectorAll('input[type="range"]')

ranges.forEach(item =>{
  
  // Recovering config on load page
  if(localStorage.getItem(item.dataset.axis)){
     document.querySelector('body').style.setProperty(`--${item.dataset.axis}`, localStorage.getItem(item.dataset.axis));
 
  item.value = localStorage.getItem(item.dataset.axis)
  }
 
  
  // Updating config values on range change
  item.addEventListener('input', (e) => {
      const val = e.target.value 
    localStorage.setItem(e.target.dataset.axis, e.target.value);
    
    document.querySelector('.feedback').classList.add('is--visible')
    
    setTimeout(function(){
      document.querySelector('.feedback').classList.remove('is--visible')
    }, 4500)

   document.querySelector('body').style.setProperty(`--${e.target.dataset.axis}`, val);
  })
  
})

document.querySelector('.js-config').addEventListener('click' ,  (e) =>{
e.target.closest('.js-config').classList.toggle('opened-controls')
})


              
            
!
999px

Console