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

Packages

Add Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="controls">
  <h3 class="controls__headline">
    Try some resizing:
  </h3>
  <div class="font-size-control">
    <span class="label">HTML font-size:</span>
    <input type="range" id="font-size-control" min="50" max="150" step="2" value="100">
    <span id="percent" class="result">100%</span>
  </div>
  <div class="font-size-control">
    <span class="label">Content --fs:</span>
    <input type="range" id="content-size-control" min="0.5" max="1.5" step="0.05" value="1">
    <span id="contentResult" class="result">1rem</span>
  </div>
  <div class="font-size-control">
    <span class="label">Sidebar --fs:</span>
    <input type="range" id="sidebar-size-control" min="0.5" max="1.5" step="0.05" value="0.75">
    <span id="sidebarResult" class="result">0.75rem</span>
  </div>
  <a class="controls__link" href="https://9elements.com/io/sizing-blocks-or-areas-using-css-custom-properties/" target="_blank">Read the Article</a>
</div>

<div class="container">
  
  <div class="content">
    <div class="teaser">
      <h2 class="teaser__headline">Headline</h2>
      <p class="teaser__body">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa, voluptatibus quia adipisci vel blanditiis voluptatum deserunt!</p>
      <a href="#" class="btn">My Button</a>
    </div>
    <div class="teaser">
      <h2 class="teaser__headline">Headline</h2>
      <p class="teaser__body">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa, voluptatibus quia adipisci vel blanditiis voluptatum deserunt!</p>
      <a href="#" class="btn">My Button</a>
    </div>
  </div>
  
  <div class="sidebar is--tiny">
    <div class="teaser">
      <h2 class="teaser__headline">Headline</h2>
      <p class="teaser__body">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa, voluptatibus quia adipisci vel blanditiis voluptatum deserunt!</p>
      <a href="#" class="btn">My Button</a>
    </div>
    <div class="teaser">
      <h2 class="teaser__headline">Headline</h2>
      <p class="teaser__body">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa, voluptatibus quia adipisci vel blanditiis voluptatum deserunt!</p>
      <a href="#" class="btn">My Button</a>
    </div>
  </div>
</div>
            
          
!
            
              :root {
  --fs: 1rem;
  --fsn: 1;
}

*, *:before, *:after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  transition: font-size 0.4s ease-out;
}

// Teaser Component
.teaser {
  font-size: var(--fs);
  width: 100%;
  max-width: 20em;
  padding: 1.5em 2em;
  box-shadow: 0 1em 1.25em -0.5em #0004;
  border-radius: 0.25em;
  margin: 0 1em 2em;

  &__headline {
    font-size: 2em;
    margin: 0 0 0.5em;
  }

  &__body {
    font-size: 1.125em;
    margin: 0 0 1em;
    line-height: 1.5;
  }
}

// Button Component
.btn {
  font-size: var(--fs);
  padding: 0.875em 1.5em 0.75em;
}

// Helper Classes for absolute sizing
// One is used for the initial sizing on the sidebar

.is--tiny {
  --fs: 0.75rem;
}
.is--small {
  --fs: 0.875rem;
}
.is--regular {
  --fs: 1rem;
}
.is--large {
  --fs: 1.25rem;
}
.is--xlarge {
  --fs: 1.5rem;
}

// ---------------------------------
// Styles not relevant for this Demo
// ---------------------------------

body {
  background: #eef;
}

.container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 100vh;
}

.content {
  font-size: var(--fs);
  padding: 1em;
  flex-grow: 99999;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  flex-basis: 22em;
  align-content: flex-start;
}
.sidebar {
  font-size: var(--fs);
  background: #003;
  padding: 1em;
  flex-grow: 1;
  display: flex;
  flex-wrap: wrap;
  flex-basis: 24em;
  align-items: flex-start;
  align-content: flex-start;
}

.teaser {
  vertical-align: top;
  background: #fff;
}

.btn {
  text-transform: uppercase;
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  background: #f09;
  color: #fff;
}

// ---------------------------------
// Interactive Controls
// ---------------------------------

.controls {
  // Everything here is set in px, as
  // I don't want it to resize itself.
  position: fixed;
  left: 10px;
  bottom: 10px;
  background: #333333cc;
  border-radius: 4px;
  
  &__headline {
    color: #fff;
    margin: 12px 18px 10px;
    font-size: 20px;
  }
  
  &__link {
    display: block;
    padding: 12px 18px 10px;
    border-top: 1px solid #333a;
    color: #0ff;
    font-weight: bold;
    letter-spacing: 0.05em;
    text-decoration: none;
    font-size: 16px;
    
    &:hover {
      text-decoration: underline;
    }
  }
}

.font-size-control {
  color: #eee;
  padding: 12px 10px 10px;
  margin: 0;
  font-size: 16px;
  border-top: 1px solid #333a;
  
  > * {
    vertical-align: middle;
    margin: 0 8px;
  }
  span {
    display: inline-block;
    min-width: 7ch;    
  }
}

.label {
  width: 120px;
  font-weight: bold;
}

.result {
  text-align: right;
}
            
          
!
            
              const htmlRange = document.getElementById('font-size-control');
const htmlResult = document.getElementById('percent');
const contentRange = document.getElementById('content-size-control');
const contentResult = document.getElementById('contentResult');
const sidebarRange = document.getElementById('sidebar-size-control');
const sidebarResult = document.getElementById('sidebarResult');
const root = document.querySelector('HTML');
const cont = document.querySelector('.content');
const side = document.querySelector('.sidebar');

htmlRange.addEventListener("input", function() {
  htmlResult.innerHTML =  htmlRange.value + "%";
  root.style.fontSize = htmlRange.value + "%";
}, false); 

contentRange.addEventListener("input", function() {
  contentResult.innerHTML =  contentRange.value + "rem";
  cont.style.setProperty('--fs', contentRange.value + 'rem');
}, false); 

sidebarRange.addEventListener("input", function() {
  sidebarResult.innerHTML =  sidebarRange.value + "rem";
  side.style.setProperty('--fs', sidebarRange.value + 'rem');
}, false); 

            
          
!
999px

Console