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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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="admin">
  <input type="range" min="10" max="35" step="1" value="20" id="slider">

  <p>Base unit is: <output id="op">20px</output><p>
</div>

<div class="Component" id="mod">
  
  <h2>Component Title</h2>
  <img src="http://placekitten.com/g/250/250" alt="Kitten">
  <p><strong>Use the range slider above</strong>.<br>The size of each element inside this module is controlled by a single unit: The <code>font-size</code>, which acts as a "root" for our em units, making everything inside the component proportionally resizable.</p>

</div>

<p class="p">Demo by Louis Lazaris. <a href="http://www.sitepoint.com/power-em-units-css/">See article</a> and <a href="https://medium.com/front-end-development/8f433689736f">original inspiration</a>.</p>
            
          
!
            
              * {
  box-sizing: border-box;
}

body {
  padding: 120px 0 0 0;
  font-family: Arial, sans-serif;
  word-break: break-word;
}

.Component {
  font-size: 20px;
  padding: 1em;
  max-width: 30em;
  border: solid 2px #ccc;
  margin: 0 auto;
  color: #666;
  border-radius: 1em 0 1em 1em;
  position: relative;
  overflow: hidden;
}

  .Component:after {
    content: '';
    display: block;
    border-radius: 50% 0 50% 50%;
    width: 2em;
    height: 2em;
    position: absolute;
    top: .2em;
    right: .2em;
    background: #bbb;
  }

  .Component h2 {
    font-size: 2em;
    margin: 0 0 .4em;
  }

  .Component img {
    max-width: 100%;
    height: auto;
    border: solid .3em #ccc;
    float: left;
    margin: 0 1em 1em 0;
  }

  .Component p {
    font-size: 1em;
    margin: 1em 0 0 0;
    text-align: left;
  }

input[type="range"] {
  margin: 20px auto;
  display: block;
}

.admin {
  position: fixed;
  background: #eee;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
}

p {
  text-align: center;
}

.p {
  font-size: 14px;
  padding-top: 100px;
}

@media screen and (max-width: 700px) {
  
  .Component {
    font-size: 14px; 
  }

}

@media screen and (max-width: 400px) {
  
  .Component {
    font-size: 10px;
    width: auto;
  }

}
            
          
!
            
              var slider = document.getElementById('slider'),
    mod = document.getElementById('mod'),
    op = document.getElementById('op');

slider.onchange = function () {
  mod.style.fontSize = this.value + 'px';
  op.innerHTML = this.value + 'px';
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console