cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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="page-content">
    <form class="" action="#">
    <select id="js-apply-size">
      <option value="small-copy">small copy</option>
      <option value="medium-copy" selected>medium copy</option>
      <option value="big-copy">big copy</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 via font size – change copy size
  </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;

.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;
    background-size: (600/$baseFontSize)+em;
  
    .transitions-enabled & {
      transition: 0.4s;    
    }
}

.sprite-1:before {
    /* Diamond: 64 × 64 px */
		width: (64/$baseFontSize)+em;
		height: (64/$baseFontSize)+em;
    background-position: 0 0;
}

.sprite-2:before {
    /* Circle: 64 × 64 px */
		width: (64/$baseFontSize)+em;
		height: (64/$baseFontSize)+em;
    background-position: (-150/$baseFontSize)+em 0;
}

.sprite-3:before {
    /* Aldus Leaf, green: 26 × 27 px */
		width: (26/$baseFontSize)+em;
		height: (27/$baseFontSize)+em;
    background-position: 0 (-150/$baseFontSize)+em;
}

.sprite-4:before {
    /* Aldus Leaf, red: 26 × 27 px */
		width: (26/$baseFontSize)+em;
		height: (27/$baseFontSize)+em;
    background-position: (-150/$baseFontSize)+em (-150/$baseFontSize)+em;
}

.sprite-5:before {
    /* Edmond O'Brien in “D.O.A.” (1949): 100 × 140 px */
		width: (100/$baseFontSize)+em;
		height: (140/$baseFontSize)+em;
    background-position: (-300/$baseFontSize)+em 0;
    margin-right: 0.4em;
}

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

.text-content {
  width: 90%;
  margin: 0 auto;
  line-height: 1.4em;
}

.small-copy {
  font-size: 0.8em;
  max-width: 520px;
}

.medium-copy {
  font-size: 1em;
  max-width: 640px;
}

.big-copy {
  font-size: 1.4em;
  max-width: 720px;
}

.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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console