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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
              <h1>Dirty &rsquo;orrible &rsquo;acky Safari resize fix</h1>
<p>Safari only: Fix for onresize inside an iframe (vw &amp; vh too).<br>For example: In a Codepen iframe.</p>

<figure>
  <figcaption>Is JavaScript no?</figcaption>
  <pre><code spellcheck=false contenteditable>// Safari only - Fix for onresize inside a Codepen iframe
(function () {
  var ua = navigator.userAgent.toLowerCase();
  if (ua.indexOf('safari') != -1) {
    if (!(ua.indexOf('chrome') > -1)) {

      // Safari only
      console.log("99 problems and Safari's just one.");
      window.addEventListener("resize", function() {
        window.location.reload(false);
      }, false);
    }
  }
}());</code></pre>
</figure>

<p>Couldn&rsquo;t find a repair for Safari failing to recalculate iframe and vw / vh sizes when the browser is resized, so wrote this.</p>
<p>It&rsquo;s certainly a dirty &rsquo;orrible &rsquo;acky fix, not recommended for production, but make&rsquo;s a good starter for ten.</p>

<p>Uses <a target=_blank title="[new window]" href="https://websemantics.uk/tools/responsive-font-calculator/">Fluid-responsive font-sizes</a> for testing purposes.</p>


    <p><a target=_blank title="[new window]" href="https://codepen.io/2kool2/pens/popular/?grid_type=list#">Pens by Mike Foskett</a> &mdash; <a target=_blank title="[new window]" href="https://websemantics.uk/">webSemantics</a></p>
            
          
!
            
              :root {
  font-size: 1rem;
  font-family: sans-serif;
  line-height: 1.5;
}
/* 1em(16px) @ 20em(320px) increasing to 2em(32px) @ 40em(640px) */
@media (min-width: 20em) {
  :root {
    font-size: calc(1rem + ((1vw - 0.2em) * 5));
    font-weight: 100;
  }
}

body {
  margin: 1rem;
  background-color: #1a1a1a;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-shadow: 1px 1px #000;
}
h1 {
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 100;
}
a {
  color: #fff !important;
  text-decoration: none;
  border-bottom: 1px solid #fff;
  transition: all .3s ease-out;
  outline: 0 solid #000;
}
a:hover,
a:focus {
  background-color: #000;
  outline: .25em solid #000;
}


figure {
  margin: 0;
  overflow: scroll;
  background-color: #3a3a3a;
  box-shadow: 0 0.25rem .5rem #000;
}
figcaption {
  padding: 0.5rem 1rem 0;
}
pre > code {
  display: block;
  padding: 0 1rem;
  outline: 0 solid;
  text-shadow: 1px 1px #000;
}
::-moz-selection {
  color: #fff;
  background-color: #000;
}
::selection {
  color: #fff;
  background-color: #000;
}
            
          
!
            
              
// Safari only - Fix for onresize inside a Codepen iframe
(function () {
  var ua = navigator.userAgent.toLowerCase();
  if (ua.indexOf('safari') != -1) {
    if (!(ua.indexOf('chrome') > -1)) {

      // Safari only
      console.log("99 browsers and Safari's just one.");
      window.addEventListener("resize", function() {
        window.location.reload(false);
      }, false);
    }
  }
}());
            
          
!
999px
🕑 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 ..................

Console