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.

              <div class=IMG>

  <h1 class=IMG_title>
    <span class=IMG_copy-1>Scaling</span>
    <span class=IMG_copy-2>font-size</span>
    <span class=IMG_copy-3>in</span>
    <span class=IMG_copy-4>prop<span>o</span>rtion</span>
    <span class=IMG_copy-5>to an</span>
    <span class=IMG_copy-6>image</span>
    <span class=IMG_copy-7><span>&harr;</span> Resize the window</span>

  <div class=IMG_bg></div>


<section class=credits>

    <li><a target=_blank title="[new window]" href="https://websemantics.uk/tools/responsive-font-calculator/">Fluid-responsive font-size calculator</a></li>

    <li>Photo: <a target=_blank title="[new window]" href="https://unsplash.com/?photo=6DivtP_WRYs">Marcus Castro</a></li>
    <li>Real world example: <a target=_blank title="[new window]" href="https://www.tesco.com/food-love-stories/">Food Love Stories</a></li>
    <li>Dirty 'orrible 'acky <a target=_blank title="[new window]" href="https://codepen.io/2kool2/pen/PKGrdj?editors=1000">Safari resize fix</a></li>

    <li><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></li>


              /* Generic styling */
* {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
body {
  font-family: sans-serif;
  line-height: 1.5;
  background-color: #B5C6AF;
h1 {font-weight: 400}
.credits {margin: 2rem}
h2 {font-weight: 100}
ul {margin-left: 1rem}
li {margin: .5rem 0}
a {
  color: #000 !important;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: all .3s ease-out;
  outline: 0 solid transparent;
a:focus {
  background-color: #fff;
  outline: .25em solid #fff;

.IMG {
  position: relative;
  /* Maintain image aspect-ratio */
  height: calc(100vw * 12 / 16);

[class^="IMG_title"] {
  position: absolute;
  z-index: 1;
  color: #fff;
  text-transform: uppercase;
  font-size: 1rem;
  /* Fluid-responsive font-size calculator: https://websemantics.uk/tools/responsive-font-calculator/ */
  /* 1em(16px) @ 20em(320px) increasing to 2em(32px) @ 40em(640px) */
  font-size: calc(1rem + ((1vw - 0.2em) * 5));
  /* WCAG: Shadow to increase contrast around text edges */
  text-shadow: 0 0 3px #000;

[class^="IMG_copy"] {
  position: absolute;
  white-space: nowrap;
.IMG_copy-1 {
  top: 20vw;
  left: 3.5vw;
  font-size: 1.125em;
.IMG_copy-2 {
  top: 41vw;
  left: 3.2vw;
  font-size: 1em;
.IMG_copy-3 {
  top: 12vw;
  left: 55.75vw;
  font-size: 1.125em;
.IMG_copy-4 {
  top: 28.75vw;
  left: 36.1vw;
  font-size: 0.75em;
  .IMG_copy-4 span{
    font-size: 2.65em;
    vertical-align: middle;
    display: inline-block;
    color: rgb(255,255,255);
    animation: color-rotate 4s infinite;
  @keyframes color-rotate {
    50% {color: #6d3; transform: scale(1.5)}
.IMG_copy-5 {
  top: 19.25vw;
  left: 73vw;
  font-size: 0.7em;
.IMG_copy-6 {
  top: 33vw;
  left: 71.4vw;
  font-size: 0.85em;
.IMG_copy-7 {
  top: 65vw;
  left: 34vw;
  .IMG_copy-7 span {
    display: inline-block;
    color: rgb(255,255,255);
    font-size: 1.5em;
    margin-right: .125em;
    vertical-align: baseline;
    animation: color-rotate-scale 2s infinite;
  @keyframes color-rotate-scale {
    50% {color: #6d3; transform: scale(1.5, 1)}

.IMG_bg {
  position: absolute;
  width: 100%;
  height: 100%;
  background-size: cover;
  /* Photo: Marcus Castro https://unsplash.com/?photo=6DivtP_WRYs */
  background-image: url(https://images.unsplash.com/photo-1496241028573-69327bf8f9d5?w=1920);
              // Dirty 'orrible 'acky fix!
// Safari only - Fix for vw / vh units 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 but Safari's just one.");
      window.addEventListener("resize", function() {
      }, false);
🕑 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 ..................