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

              <h2>vw method</h2>
<div class="vw-method box">
  <p>If the width of the box is 100% of the viewport, you can use a height with a vw value. (1vw is 1/100th of the width of the viewport.)
      <li>No extra wrappers necessary. 
      <li>Less scss.

    <li>less browser compatible (no IE8 and below)</li> 
    <li>(In Chrome at least) vw includes the scrollbar in the calculation, so the ratio is not perfect when scrollbars are present.</li>

<h2>padding/absolute method</h2>
<div class="padding-absolute-method box">
  <div class="content">
    <p>Using an extra wrapper, padding on a before pseudo class and absolutely positioning the inner div method.</p>
    <p>This works because a padding percentage (even for top or bottom padding) is calculated based on the WIDTH of the element.</p>

    <li>More compatible.
    <li>Not limited to full viewport width. (Can be used at any width.)
    <li>Extra inner wrapper required.
    <li> blah
    <li> blah
              .vw-method {
  width: 100%;
  //Change the height to the desired aspect ratios width divided by height times 100vw
  height: 1/8 * 100vw; //8:1 ratio
  //height: 33.33vw; //3:1 ratio
  //height: 66.66vw; //3:2 ratio
  //height: 9/16 * 100vw; //16:9 ratio
  //height: 1/2 * 100vw; //2:1 ratio  

@mixin aspect-ratio($width, $height) {
  position: relative;
  &:before {
    display: block;
    content: "";
    width: 100%;
    padding-top: ($height / $width) * 100%;
  > div {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

.padding-absolute-method {
  // Change the parameters of this mixin to any desired aspect ratio.
  @include aspect-ratio(8,1);

.box {
  padding: 0px;
  background-color: #46433A;
  color: #dcd2b9;
  margin:0px 0px 50px 0px;

/* Irrelevant styling CSS */

@import url(https://fonts.googleapis.com/css?family=Merriweather:300,300italic|Lato:900,900italic);

body {
    font-family: Merriweather,Georgia,Times,"Times New Roman",serif;
    color: #46433A;
    font-size: 16px;
    font-size: 1rem;
    line-height: 1.5;
    // lighter background
    background-color: #E2D9C4;
    // slightly darker background
    background-color: rgb(219, 208, 182);
    margin: 0;
    font-weight: 300;

h1, h2, h3, h4, h5, h6 {
    font-family: Lato,"Helvetica Neue","Segoe UI",Arial,sans-serif;
    text-rendering: optimizeLegibility;
    font-weight: 900;
    text-align: center;
🕑 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.
Loading ..................