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.

Quick-add: + add another resource

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.

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=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>
  </h1>

  <div class=IMG_bg></div>

</div>


<section class=credits>
  
  <h2>Credits</h2>
  <ul>

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

</section>

            
          
!
            
              /* 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:hover,
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() {
        window.location.reload(false);
      }, false);
    }
  }
}());
            
          
!
999px
Loading ..................

Console