Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="adjust">
  <p>leading (line-height)</p>
  <input type="range" min="25" max="500" value="130" class="slider" id="myRange">
  <p><span id="value"></span><span id="percent">%</span></p>
</div>
<div class="container"><p><span id="words"><mark>What is called <em>line-height</em> in CSS is also known as <em>leading</em> in graphic design. The name comes from the thin strips of lead that typesetters would put between lines of type to increase vertical distance. Line-height between 120% and 150% is best for legibility. Anything less and the lines can overlap. Anything more and the lines are too far apart to read quickly.</mark></span></p></div>

  
              
            
!

CSS

              
                /*importing google fonts */
@import url('https://fonts.googleapis.com/css?family=Merriweather');
@import url('https://fonts.googleapis.com/css?family=Montserrat:600');

body {background-color:#dddeee;}

/* start body of text */

.container {
  width:70%;
  margin:2%;
  float:right;
}

#words{
  font-family: 'Merriweather', serif;
  font-size:2em;
}

mark {
  background-color:#fff;
  
}

/* end body of text */

/* start sidebar */

.adjust{
  float:left;
  margin:2%;
  width:22%;
  text-align:center;
  background-color:#fff;
  border-radius:7px;
}

.adjust p {
  font-family: 'Montserrat', sans-serif; 
  font-size:.8em;
}

#value, #percent {
  font-size:2em;
  color: #245341;
}


#myRange {
    -webkit-appearance: none;
    padding:0;
    margin:0;
    width: 100%;
    height: 10px;
    background: #dddeee;
    outline: none;
    -webkit-transition: .2s;
    transition: opacity .2s;
}


#myRange::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 17px;
    height: 17px;
    border-radius:30px;
    background: #222;
    cursor: pointer;
}

#myRange::-moz-range-thumb {
    width: 17px;
    height: 17px;
    border-radius:30px;
    background: #222;
    cursor: pointer;
}

/* end sidebar */
              
            
!

JS

              
                //based on helpful examples from w3schools.com

var slider = document.getElementById("myRange");
var output = document.getElementById("value");
output.innerHTML = slider.value; // Display the default slider value


// Update the current slider value (each time you drag the slider handle)
slider.oninput = function() {
    output.innerHTML = this.value;
    
    // change the line height based on the slider value
    var lh = slider.value / 100;
    document.getElementById("words").style.lineHeight = lh ;
  
  // if the slider value is outside of optimum legibility, make the label red
  if (slider.value < 120) {
    document.getElementById("value").style.color = "#d65836";
    document.getElementById("percent").style.color = "#d65836";
  } 
  else if (slider.value > 150) {
   document.getElementById("value").style.color = "#d65836";
  document.getElementById("percent").style.color = "#d65836"; 
  }  
  
  else {
    document.getElementById("value").style.color = "#33765f";
  document.getElementById("percent").style.color = "#33765f"; 
  }
  
}



              
            
!
999px

Console