Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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 id="savings-calculator">
  <h1>Savings Calculator</h1>
  <p>Save Up to <strong>35%</strong> On Your Energy Bills!</p>
  <hr>
  <label>How Much is Your Energy Bill Each Month?</label>
  <div class="range-slider">
    <input type="range" id="energyBill" name="energyBill" min="50" max="700" value="50" step="10">
    <strong>$<span id="range-value">50</span></strong>
    <!--<select>
  <option>$10</option>
  <option>$20</option>
  <option>$30</option>
  <option>$40</option>
  <option>$50</option>
  <option>$60</option
</select>-->
  </div>

  <h3>You could save up to <span id="savingsYearly" class="two-digits">$204</span> per year!</h3>
  <p>Estimated Monthly Savings: <span id="savingsMonthly" class="two-digits">$17</span></p>
  <a class="btn" href="#">Start Saving Today!</a>
  <i class="disclaimer">*This is an estimate based on average savings of our customers. While your savings may vary, we're committed to help you find the most energy efficient solution possible for your home.</i>
</div>
              
            
!

CSS

              
                body {
  font-family: sans-serif;
  text-align: center;
  background: #f5f5f5;
}

#savingsYearly, #savingsMonthly {
  color: #4c9612;
}

#savingsMonthly {
  font-weight: 700;
}

#savingsYearly {
  display: block;
  font-size: 60px;
}

#energyBill {
  margin-top: 10px;
}

#savings-calculator {
  display: block;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  padding: 35px 20px;
  background: #fff;
  box-shadow: 0 8px 20px -3px rgba(0,0,0,0.3);
  margin-top: 30px;
  margin-bottom: 30px;
  border-radius: 6px;
  box-sizing: border-box;
}

hr {
  margin: 20px 0;
  background: #ddd;
  border: none;
  height: 1px;
}

img {
  width: 100%;
  max-width: 200px;
  margin:0;
}

h1 {
  margin-top: 0;
}

.btn {
  background-image: linear-gradient(to bottom,#009DDD,#0c65a7);
    font-size: 20px;
    font-weight: 300;
    color: #fff;
    display: inline-block;
    padding: 24px 20px;
    position: relative;
    text-decoration: none;
    border: solid 1px transparent;
    border-radius: 4px;
    min-width: 200px;
    -webkit-transition: all .1s ease-in-out;
    -moz-transition: all .1s ease-in-out;
    -ms-transition: all .1s ease-in-out;
    -o-transition: all .1s ease-in-out;
    transition: all .1s ease-in-out;
    width: 100%;
  cursor: pointer;
  box-sizing: border-box;
  display: inline-block;
}

label {
  margin-bottom: 10px!important;
  display: block;
}

#energyBill {
  width: 230px;
  max-width: 100%;
  -webkit-appearance: none;
  height: 15px;
  border-radius: 10px;
  background: #d3d3d3;
  outline: none;
  opacity: 1;
}
  
#energyBill::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 25px;
  height: 25px;
  background: white;
  cursor: pointer;
  border-radius: 50%;
  border: solid 8px #7AC142;
  border: solid 8px #4c9612;
  border: solid 8px #009DDD;
  border: solid 8px #0c65a7;
}

#energyBill::-moz-range-thumb {
  width: 25px;
  height: 25px;
  background: #7AC142;
  cursor: pointer;
}

i.disclaimer {
  margin-top: 10px;
  font-size: 9px;
  color: #999;
  line-height: 1.4em!important;
  display: block;
}
              
            
!

JS

              
                // Regex function plugin to add commas to numbers
$.fn.digits = function(){ 
  return this.each(function(){ 
    $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
  })
}

function isNumber (o) {
  return ! isNaN (o-0);
}  

// Adjust range number when changed
$('input[type=range]').on('input', function () {

  // Get number of attendees in range slider
  var energyBill = $('#energyBill').val();

  // Insert number of attendees in span
  $('#range-value').text(energyBill);

  var energySavings = Math.trunc(energyBill * 0.35);
  var energySavingsYearly = Math.trunc(energySavings * 12);

  $('#savingsMonthly').text('$' + energySavings);
  $('#savingsYearly').text('$' + energySavingsYearly);
  
  // Add commas to number
  $('#range-value').digits();
  $('#savingsMonthly').digits();
  $('#savingsYearly').digits();
    
});

              
            
!
999px

Console