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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm 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. We'll also process your JavaScript with Babel.

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

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.

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="container container--spaced">
  <label>Using relative Pixel values</label>
  <div class="test">
    <div class="imagebox">image</div>
    <h1>Lorem ipsum dolor sit amet, consectetur adipisici elit.</h1>

    <p>Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna
      aliqua. Nec dubitamus multa iter quae et nos invenerat. Idque Caesaris facere voluntate liceret: sese habere.
      Inmensae subtilitatis, obscuris et malesuada fames. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed
      nibh.</p>
  </div>
</div>

<div class="container container--centered">
  <span class="help">Change your browser's default font size in the settings to see a difference here.</span>
</div>
<hr>

<div class="container container--spaced">
  <label>Using absolute Pixel values</label>
  <div class="test use-px">
    <div class="imagebox">image</div>
    <h1>Lorem ipsum dolor sit amet, consectetur adipisici elit.</h1>

    <p>Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna
      aliqua. Nec dubitamus multa iter quae et nos invenerat. Idque Caesaris facere voluntate liceret: sese habere.
      Inmensae subtilitatis, obscuris et malesuada fames. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed
      nibh.</p>
  </div>
</div>


            
          
!
            
              // PX to REM conversion function
@function rem($pixels) {
  // Divide the pixel value by 16 (default font size)
  // Mulitplication by 1rem is needed to set the correct unit for the resulting value
  @return ($pixels / 16) * 1rem;
}

// HTML and Body styling
html {
  // Set 16 px as the base font size, currently the default in all browsers
  // 100% = 1em = 1rem = 16px = 12pt
  font-size: 100%;
  font-family: sans-serif;
}

body {
  // Set the base font size of the body to 16px = 1rem
  font-size: 1rem;
}

// Typo styles
p {
  font-size: rem(18);

  .use-px & {
    // Use a fixed value of 18px for the element
    font-size: 18px;
  }
}

h1 {
  font-size: rem(35);
  margin: rem(10) 0 0;

  .use-px & {
    font-size: 35px;
    margin: 10px 0 0;
  }
}

// Dimension and spacing styles
.test {
  padding: rem(15);

  .use-px & {
    padding: 15px;
  }
}

.imagebox {
  width: rem(150);
  height: rem(150);
  margin-left: rem(50);
  margin-bottom: rem(20);

  .use-px & {
    width: 150px;
    height: 150px;
    margin-left: 50px;
    margin-bottom: 20px;
  }
}


//===========================================================================
// Styles without function for the font sizing, just to make things look nice
.container {
  position: relative;
  margin: 0 auto;
  padding: 0 rem(10);
  max-width: rem(1000);

  &--spaced {
    margin-top: rem(50);
    margin-bottom: rem(50);
  }

  &--centered {
    text-align: center;
  }
}

label {
  font-size: rem(9);
  text-transform: uppercase;
  font-weight: bold;
  color: #0078ff;
}

.test {
  background: #f5f5f5;

  &:after {
    content: "";
    clear: both;
    display: table;
  }
}

.imagebox {
  display: flex;
  justify-content: center;
  align-items: center;
  float: right;
  background: #ddd;
  color: #888;
}

hr {
  width: 100%;
  margin: 0;
  background: none;
  border: 0;
  border-bottom: 2px dashed #eee;
}

.help {
  display: block;
  transform: translateY(calc(100% - #{rem(3)}));
  font-size: rem(9);
  font-weight: bold;
  color: #999;
  line-height: 1;
}

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console