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.

            
              <div class="page-content">
    <form class="" action="#">
    <select id="js-apply-size">
      <option value="small-copy">small width</option>
      <option value="medium-copy" selected>medium width</option>
      <option value="big-copy">full width</option>
    </select>
    <select id="js-apply-sprite">
      <option value="sprite-1" selected>Sprite #1 – Green Spade</option>
      <option value="sprite-2">Sprite #2 – Red Circle</option>
      <option value="sprite-3">Sprite #3 – Aldus Leaf, green</option>
      <option value="sprite-4">Sprite #4 – Aldus Leaf, red</option>
      <option value="sprite-5">Sprite #5 – Edmund O'Brien</option>
    </select>
    <select id="js-apply-spritemap">
      <option value="spritemap-svg" selected>SVG</option>
      <option value="spritemap-png-hi">PNG ×2</option>
      <option value="spritemap-png-lo">PNG lo-res</option>
    </select>
    <input id="js-enable-transitions" type="checkbox" value="transitions-enabled" checked="checked"> <label for="js-enable-transitions">transitions</label>
  </form>
<div class="text-content spritemap-svg transitions-enabled medium-copy">
  <div class="author">
    <span class="sprite sprite-1"></span>Scaling precentage-wise – scale window
  </div>
  <p>Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musica, sport etc, litot Europa usa li sam vocabular.</p>

  <p>Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilite de un nov lingua franca: On refusa continuar payar custosi traductores.</p>
</div>
</div>

            
          
!
            
              $baseFontSize: 18; //px
$baseElementSize: 640; // px

.spritemap-svg .sprite:before {
    background-image: url('https://ssl-account.com/stolzenhain.net/content/1-responsive-spritemaps/spritemap.svg'); /* 600 × 450 px */  
}

.spritemap-png-hi .sprite:before {
    background-image: url('https://ssl-account.com/stolzenhain.net/content/1-responsive-spritemaps/spritemap-144dpi.png'); /* 600 × 450 px */  
}

.spritemap-png-lo .sprite:before {
    background-image: url('https://ssl-account.com/stolzenhain.net/content/1-responsive-spritemaps/spritemap-36dpi.png'); /* 600 × 450 px */  
}

.sprite:before {
  	content: "";
    display: inline-block;

    .transitions-enabled & {
      transition: 0.4s;    
    }
}

.sprite-1:before {
    /* Diamond: 64 × 64 px */
		width: (64/$baseElementSize*100%);
		padding-top: (64/$baseElementSize*100%);
		height: 0;
    background-position: 0 0;
    background-size: (600/64*100%) auto; /* spritemap size ÷ sprite size × 100% */
}

.sprite-2:before {
    /* Circle: 64 × 64 px */
		width: (64/$baseElementSize*100%);
    padding-top: (64/$baseElementSize*100%);
		height: 0;
    background-size: (600/64)*100% auto; /* spritemap size ÷ sprite size × 100% */
    background-position: ((150)/(600-64)*100%) 0; /* (sprite offset) ÷ (spritemap size - sprite size) × 100% */

}

.sprite-3:before {
    /* Aldus Leaf, green: 26 × 27 px */
		width: (26/$baseElementSize*100%);
		padding-top: (27/$baseElementSize*100%);
    height: 0;
    background-size: (600/26)*100% auto; /* spritemap size ÷ sprite size × 100% */
    background-position: 0 ((150)/(450-27)*100%); /* (sprite offset) ÷ (spritemap size - sprite size) × 100% */
}

.sprite-4:before {
    /* Aldus Leaf, red: 26 × 27 px */
		width: (26/$baseElementSize*100%);
		padding-top: (27/$baseElementSize*100%);
    height: 0;
    background-size: (600/26)*100% auto; /* spritemap size ÷ sprite size × 100% */
    background-position: ((150)/(600-26)*100%) ((150)/(450-27)*100%); /* (sprite offset) ÷ (spritemap size - sprite size) × 100% */
}

.sprite-5:before {
    /* Edmond O'Brien in “D.O.A.” (1949): 100 × 140 px */
		width: (100/$baseElementSize*100%);
		padding-top: (140/$baseElementSize*100%);
    height: 0;
    background-size: (600/100)*100% auto; /* spritemap size ÷ sprite size × 100% */
    background-position: ((300)/(600-100)*100%) 0; /* (sprite offset) ÷ (spritemap size - sprite size) × 100% */
    margin-right: 0.4em;
}

body {
  font-size: $baseFontSize+px;
  font-family: sans-serif;
  line-height: 1.4em;
  background-color: white;
}

.text-content {
  width: 90%;
  margin: 0 auto;
  line-height: 1.4em;
  position: relative;
  
  &.transitions-enabled {
    transition: 0.6s;
  }
}

.small-copy {
  font-size: 0.8em;
  max-width: 40%;
}

.medium-copy {
  font-size: 1em;
  max-width: 64%;
}

.big-copy {
  font-size: 1.4em;
  max-width: 90%;
}

.author {
    margin-bottom: 1em;  
}

form {
  text-align: center;
  margin-bottom: 2em;
}

input,
select {
  margin: 0 0.4em;
}

            
          
!
            
              $(function(){
  
  var classLookup = {
    'apply-size' : 'medium-copy',
    'apply-spritemap' : 'spritemap-svg',
    'enable-transitions' : 'transitions-enabled'
  }
  
  function updateClasses() {
    var setClasses = [];
    for (var key in classLookup) {
      if (classLookup.hasOwnProperty(key)) {
        setClasses.push(classLookup[key]);
      }
    }
    $('.text-content').attr('class', 'text-content '+setClasses.join(' '));
  }
    
  $('#js-apply-sprite').on('change',function(){
    var setClass = $(this).find(':selected').attr('value');
    $('.sprite').attr('class', 'sprite '+setClass);
  });
  
  $('#js-apply-size').on('change',function(){
    classLookup['apply-size'] = $(this).find(':selected').attr('value');
    updateClasses();
  });
  
  $('#js-apply-spritemap').on('change',function(){
    classLookup['apply-spritemap'] = $(this).find(':selected').attr('value'); 
    updateClasses();
  });
  
  $('#js-enable-transitions').on('change',function(){
    classLookup['enable-transitions'] = $(this).filter(':checked').attr('value') || 'transitions-disabled'; 
    updateClasses();
  });

});
            
          
!
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