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="content aspectratio" data-ratio="16:9">
              .aspectratio {
  position: relative;

.aspectratio:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: -1;
  /* visual helper */
  outline: 2px solid blue;

.aspectratio[data-ratio="16:9"]:after {
  padding-top: 56.25%;

.aspectratio[data-ratio="4:3"]:after {
  padding-top: 75%;

.content {
  /* try stretching out the box … but this fails */
  height: 100%;
  width: 100%;
  /* visualize the box */
  background: hotpink;
  /* center my children */
  display: flex;
  align-items: center;
  justify-content: center;

/* other styles, not directly required for the demo */
@keyframes change {
  0% { width: 50vw; }
  100% { width: 80vw; }

main {
  width: 50vw;
  margin: 0 auto;
  animation: change 5s linear alternate infinite;
Loading ..................