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.

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