css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

    <h1>Here is an H1 title</h1>
    <h2>Here is an H2 subhead, resize your browser to see the ratio difference</h2>
    <p>Here is some body text, here is some more, check it out, body text!</p>
 * CSS variables have 77% global browser support
 * update: now up to 87%! 
 * But they don't work in IE,
 * so we can use Sass for a fallback
 * @link https://caniuse.com/#search=css%20variables
 * Another consideration is that 90%+ of mobile devices support CSS variables, so you could flip the media query to mobile and make it variable-only and use IE fallback code only for desktop.

 * Set fallback base font and scale ratio with Sass 
 * Use these numbers with :root when removing fallback

$font-size: 100%; // 16px
$ratio: 1.12;
$ratio-large: 1.25;

/* Create Sass type sizes */

$h4: $font-size * $ratio;
$h3: $h4 * $ratio;
$h2: $h3 * $ratio;
$h1: $h2 * $ratio;

/* Sass second scale with larger type sizes */

$h4-large: $font-size * $ratio-large;
$h3-large: $h4-large * $ratio-large;
$h2-large: $h3-large * $ratio-large;
$h1-large: $h2-large * $ratio-large;

 * Use Sass variables with CSS variables for single variable source
 * Replace these with above numbers in the future 
 * It appears Sass variables need to be interpolated to strings to work with CSS variables

:root {
  --font-size: #{$font-size};
  --ratio: #{$ratio};
  --ratio-large: #{$ratio-large};

 * Set heading sizes with CSS variables
 * any browser that can support variables will support Calc
 * CSS Calc has 94% support
 * @link https://caniuse.com/#feat=calc

  --h4: calc(var(--font-size) * var(--ratio));
  --h3: calc(var(--h4) * var(--ratio));
  --h2: calc(var(--h3) * var(--ratio));
  --h1: calc(var(--h2) * var(--ratio));

p {
  font-size: $font-size; /* variable fallback for IE11 */
	font-size: var(--font-size);

h1 {
  font-size: $h1; /* variable fallback for IE11 */
  font-size: var(--h1);

h2 {
  font-size: $h2; /* variable fallback for IE11 */
	font-size: var(--h2);

/* switch to larger ratio */

@media screen and (min-width: 800px) {
    :root {
    --ratio: var(--ratio-large); 
 * 1. Variable fallback for IE11. When no longer supporting IE11, these can be removed and the ratio can be changed with the single variable change above.
 * This method generates more code than Sass alone but preps the stylesheet for less code with vanilla CSS in the long run
  h1 {
   font-size: $h1-large; /* 1 */
  h2 {
    font-size: $h2-large; /* 1 */
🕑 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 ..................