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

              
                <div id="spousal-support-calculator">
  
  <h1>Spousal Support Calculator</h1>
  
  <ul id="ssc-time-frame">
    <li id="ssc-time-monthly" class="active">Monthly Income</li>
    <li id="ssc-time-yearly">Yearly Income</li>
  </ul>
  
  <div id="ssc-input">
    <div class="ssc-input-wrapper" id="ssc-input-income">
      <label>What is your <span id="ssc-input-time">monthly</span> income?</label>
      <div id="ssc-input-field-wrapper"><input id="ssc-input-field" type="number"></div>
    </div>
    
    <div class="ssc-input-wrapper" id="ssc-input-marriage">
      <label>How long were you married?</label>
      <div id="ssc-marriage-radios">
        <label id="ssc-marriage-years-1"><input type="radio" name="marriage" value="1" checked>1-9 years*</label>
        <label id="ssc-marriage-years-10"><input type="radio" name="marriage" value="10">10-19 years</label>
        <label id="ssc-marriage-years-20"><input type="radio" name="marriage" value="20"> 20-29 years</label>
        <label id="ssc-marriage-years-30"><input type="radio" name="marriage" value="30"> 30+ years</label>
      </div>
    </div>
        
    <div><button id="ssc-input-button"><i class="fas fa-calculator"></i> Calculate</button></div>
    
  </div>
  
  <div id="ssc-output">
    <h2>You'd pay <span class="ssc-underline">$<span id="ssc-output-monthly">0</span> per month</span> in spousal support for a <span class="ssc-underline">maximum of <span id="ssc-output-years">0</span> years</span>.**</h2>
  <h4>On a yearly basis, you'd pay $<span id="ssc-output-yearly">0</span> total in spousal support.</h4>
  </div>
  
  <div id="ssc-disclaimers">
    <p id="ssc-disclaimer-family-violence">*Only applies to cases of family violence conviction.</p>
    <p id="ssc-disclaimer-general">**Insert a general disclaimer here.</p>
  </div>

</div>
              
            
!

CSS

              
                body {
  font-family: sans-serif;
  margin: 40px;
}

#ssc-time-frame {
  padding: 0;
}

.ssc-underline {
  position: relative;
  color: #f57708;
}

.ssc-underline::after {
  content: "";
  position: absolute;
  bottom: -5px;
  width: 100%;
  height: 3px;
  background: #f57708;
  left: 0;
  right: 0;
}

#ssc-time-frame li {
  opacity: 0.5;
  list-style: none;
  display: inline-block;
  padding: 5px 10px;
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 15px;
  transition: all ease 0.3s;
  background: #ccc;
  color: #555;
}

#ssc-time-frame li:hover {
  opacity: 1;
}

#ssc-time-frame li.active {
  opacity: 1;
  background: #000;
  color: #fff;
}

#ssc-input .ssc-input-wrapper > label {
  display: block;
  font-weight: 700;
}

#ssc-input #ssc-input-field {
  height: 41px;
  box-sizing: border-box;
  padding: 0 10px;
  font-size: 16px;
  border: none;
  outline: none;
}

#ssc-input-field-wrapper {
  border: solid 1px #000;
  display: inline-block;
  margin-top: 10px;
}

.ssc-input-wrapper {
  margin-bottom: 20px;
}

#ssc-input-field-wrapper::before {
  content: "$";
  padding: 0 20px;
  line-height: 44px;
  background: black;
  color: #fff;
  display: inline-block;
  box-sizing: border-box;
}

#ssc-input-button {
  padding: 18px 50px;
  border-radius: 4px;
  border: none;
  color: #fff;
  font-weight: 700;
  background: #f57708;
  font-size: 18px;
  outline: none;
  cursor: pointer;
}

#ssc-marriage-radios label, #ssc-marriage-radios input {
  cursor: pointer;
}

#ssc-marriage-radios label {
  display: inline-block;
  margin: 10px 10px 5px 0;
}

#ssc-disclaimers p {
  font-style: italic;
  font-size: 12px;
}

#ssc-output {
  margin: 15px 0;
  padding: 15px 35px;
  border: solid 1px #ddd;
  border-radius: 6px;
  display: inline-block;
}

#ssc-output h2 {
  line-height: 1.4em;
}
              
            
!

JS

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

// Choose Monthly or Yearly Income
jQuery('#ssc-time-frame li').click(function() {
  jQuery(this).addClass('active').siblings().removeClass('active');
});

jQuery('#ssc-time-monthly').click(function() {
  jQuery('#ssc-input-time').text('monthly');
});

jQuery('#ssc-time-yearly').click(function() {
  jQuery('#ssc-input-time').text('yearly');
});

// Click Calculate Button
jQuery('#ssc-input-button').click(function() {
  
  // Number of Years
  if( jQuery('#ssc-marriage-years-1 input').is(':checked') ) {
    jQuery('#ssc-output-years').text('5');
  };
  
  if( jQuery('#ssc-marriage-years-10 input').is(':checked') ) {
    jQuery('#ssc-output-years').text('5');
  };
  
  if( jQuery('#ssc-marriage-years-20 input').is(':checked') ) {
    jQuery('#ssc-output-years').text('7');
  };
  
  if( jQuery('#ssc-marriage-years-30 input').is(':checked') ) {
    jQuery('#ssc-output-years').text('10');
  };
  
  // Payment Amounts
  var incomeValue = jQuery('#ssc-input-field').val();
  
  if( jQuery('#ssc-time-monthly').hasClass('active') ) {
    
    var monthlyPayment = incomeValue * 0.20;
    var yearlyPayment = incomeValue * 0.20 * 12;
  };
  
  if( jQuery('#ssc-time-yearly').hasClass('active') ) {
    var monthlyPayment = incomeValue * 0.20 / 12;
    var yearlyPayment = incomeValue * 0.20;
  };
  
  if(monthlyPayment > 5000) {
    var monthlyPayment = 5000;
    var yearlyPayment = monthlyPayment * 12;
  };
  
  jQuery('#ssc-output-monthly').text(monthlyPayment.toFixed(0)).digits();
  jQuery('#ssc-output-yearly').text(yearlyPayment.toFixed(0)).digits();
  
});


              
            
!
999px

Console