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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <html>

<head>
  <!-- Material Design Lite -->
  <script src="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"></script>
  <link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.cyan-amber.min.css">
  <!-- Material Design icon font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>

<body>

  <div class="mdl-card mdl-shadow--2dp animated slideInUp">
    <div class="mdl-card__supporting-text cyan">
      <p class="installment-label animated slideInDown">Monthly Installment</p>
      <p id="installment_value" class="installment-value animated slideInDown">$ 0.00</p>
    </div>
    <div class="mdl-card__supporting-text">
      <form action="#">
        <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
          <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="car_price" tabindex="1">
          <label class="mdl-textfield__label" for="sample4">Car Price</label>
          <span class="mdl-textfield__error">Price is not a number!</span>
        </div>
        <br>
        <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
          <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="deposit" tabindex="2">
          <label class="mdl-textfield__label" for="sample4">Deposit</label>
          <span class="mdl-textfield__error">Deposit is not a number!</span>
        </div>
        <br>
        <div class="mdl-textfield mdl-js-textfield animated slideInLeft">
          <p>
            <label class="slider-label">Repayment Period:</label>
            <label id="repayment_value" class="slider-value"></label>
            <label class="slider-value">Year(s)</label>
          </p>
          <input id="repayment_slider" class="mdl-slider mdl-js-slider" type="range" min="1" max="9" value="6" tabindex="3">
        </div>
        <br>
        <div class="mdl-textfield mdl-js-textfield animated slideInLeft">
          <p>
            <label class="slider-label">Interest rate / year:</label>
            <label id="interest_value" class="slider-value"></label>
            <label class="slider-value">%</label>
          </p>
          <input id="interest_slider" class="mdl-slider mdl-js-slider" type="range" min="0.1" max="5" value="2.5" step="0.1" tabindex="4">
        </div>
      </form>
    </div>
  </div>
  
</body>

</html>
              
            
!

CSS

              
                body {
  padding: 20px;
  background: #eceff1;
  position: relative;
}

.mdl-card{
  margin:0 auto;
}

.slider-label{
  color:#9E9E9E;
}

.tool-label{
  color:#00BCD4;
  font-size: 24px;
}

.installment-label{
  color:#FFFFFF;
  text-align:center;
}

.installment-value{
  color:#FFFFFF;
  text-align:center;
  font-size:28px;
}

.slider-value{
  font-weight:bold;
}

.installment-value{
  text-align:center;
  font-weight:bold;
}

.cyan {
    color:#FFFFFF;
    background-color: #2196F3;
}
              
            
!

JS

              
                var calc_loan = function() {
  var value = 0;
  var n = $('#repayment_slider').val()*12;
  var r = ($('#interest_slider').val()/100)/12;
  var R = Math.pow(r+1,n);
  var P = $('#car_price').val();
  var d = $('#deposit').val();
  value=(P-d)*((r*(R))/(R-1));
  $('.installment-value').text("$ " + Humanize.formatNumber(value, 2));
}
$('#repayment_value').text($('#repayment_slider').val());
$('#interest_value').text($('#interest_slider').val());

$('#car_price').change(function(event) {
  calc_loan();
});

$('#deposit').change(function(event) {
  calc_loan();
});

$('#repayment_slider').change(function(event) {
  $('#repayment_value').text($('#repayment_slider').val());
  calc_loan();
});

$('#interest_slider').change(function(event) {
  $('#interest_value').text($('#interest_slider').val());
  calc_loan();
});
              
            
!
999px

Console