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

              
                <h2>Scaling HTML UI elements with CSS rem/em units</h2>

<p>This example shows how to scale HTML UI elements using a combination of rem and em units. </p>

<label id="label-font-size" for="font-size">
   Font size (as rem unit)
</label>
<div id="font-size-container">
   <input id="font-size" type="range" min=".3" max="2"
          step=".05" value=".5"/>
   <span id="selected-font-size"></span>
</div>   

<div class="all-criers-container" id="town-crier" style="">
   <div class="crier">
      <div class="icon-container dark">
         <i class="fa fa-exclamation-triangle"></i>
      </div>
      <div class="text">
         <div class="headline">
            Warning
         </div>
         <div class="detail">
            The Under Keyboard Zipper Monitor&trade; shows that your pants are unzipped. This is potentially a critical situation.
         </div>
      </div>
      <div class="close-icon">
         <a class="crier-close" title="You must click to close this"><i class="fa fa-window-close"></i></a>
      </div>
   </div>
</div>


              
            
!

CSS

              
                body {
   font-family: sans-serif;  
   font-size: 16px;
}

.all-criers-container {
  pointer-events: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 97vw;
  z-index: 500;
  padding: 1rem;
   
  display: grid;
  grid-template-rows: auto;
  grid-row-gap: 15px;
  justify-items: end;
  justify-content: end;
}

.crier {
   display: grid;
   grid-template-columns: 7em 6fr 3em;

   background-color: #F4FA58;
   border-radius: .5em;
   box-shadow: .2em .2em .2em .1em rgba(0, 0, 0, 0.2);
   font-family: sans-serif;
   font-size: .5rem; 
   font-family: sans-serif;   
   max-width: 70em;
   overflow: hidden; 
   opacity: 1;
   z-index: 600;
}

.crier  .text {
  padding: 1em;
  overflow: hidden;
}

div.crier .headline {
  font-size: 3em;
  font-weight: 600;
  overflow: hidden;
  padding-left: .3em;
}

.detail {
  font-size: 2em; 
  padding-top: 0.5em;
  padding-bottom: 0.3em;
  padding-left: .3em;
}

.crier a {
  color: black;
}

.icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5em;
  color: black;
  background-color: darkgray;  
  border-top-left-radius: .1em;
  border-bottom-left-radius: .1em;
}

.close-icon {
  padding-top: .3em;
  font-size: 2em;
}


/* ------------------------------ */

div#font-size-container {
   display: flex;
   align-items: flex-start;
   margin-top: .5rem;
   margin-bottom: 1rem;   
}

input {
   margin-right: .5rem;
}
              
            
!

JS

              
                const changeFontSizeCardUses = (fontSize) => {
   const crier = document.querySelector('.crier');
   crier.style.fontSize = fontSize;   
}

const showSelectedFontSize = () => {
   const fontSize = document.getElementById('font-size').value; 
   const showFontSize = document.getElementById('selected-font-size');
   const newFontSize = `${fontSize}rem`;   
   showFontSize.innerHTML = newFontSize;   
   return newFontSize;
}

document.getElementById('font-size').addEventListener('change', (e) => {
   const fs = showSelectedFontSize();
   changeFontSizeCardUses(fs);
})

const fs = showSelectedFontSize();
changeFontSizeCardUses(fs);
              
            
!
999px

Console