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.

              <h1><code>canvas/svg</code> 2:1 aspect ratio is preserved</h1>

<div class="Icon" style="height:2rem">
  <canvas class="Icon-canvas" height="1" width="2"></canvas>
  <svg class="Icon-svg"></svg>


<div class="Icon" style="height:5rem">
  <canvas class="Icon-canvas" height="1" width="2"></canvas>
  <svg class="Icon-svg"></svg>
              svg { background: #55acee; }
 * IE 9–11 do not preserve the aspect ratio of the svg. The svg element
 * will default to a width of 300px (the default for replaced content
 * elements).
 * A canvas of the correct aspect ratio is used to provide a scalable frame.
 * The svg is positioned to fit the frame.

 * 1. Default height of the icon. Allows the icon to scale with font-size, or
 *    be directly sized.
 * 2. Create a positioning context.
.Icon {
  display: inline-block;
  height: 1.25em; /* 1 */
  position: relative; /* 2 */
  user-select: none;

 * Framing element. The dimensions of the canvas are determined by the outer view.
 * 1. Make the canvas fill all vertical space so that the icon can be resized
 *    in context.
 * 2. Ensure the canvas is never visible.
.Icon-canvas {
  display: block;
  height: 100% !important; /* 1 */
  visibility: hidden; /* 2 */

 * Absolutely position the svg within the frame.
.Icon-svg {
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;

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.


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