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

              
                <link href='https://fonts.googleapis.com/css?family=Work+Sans:300,400' rel='stylesheet' type='text/css'>

<section class="calculator" id="body">
<form action="" class="wage-gap" id="wage-gap" onsubmit="return false;">
  When I invest 
  <span class="salary-initial">
	<input type="number" min="0" step="100" id="salary-initial" name="salary-initial" onchange="calculateTotal()"/><label class="input__label">	<span class="input__label-content">$</span></label></span>,
  
  <span class="input">
  <select class="input" id="womanethnicity" name="womanethnicity" onchange="calculateTotal()"></span>
    <option value="autotrader">
      in autoTRADER
    </option>
    <option value="social">
     in Social
    </option>
    <option value="search">
      in Search
    </option>
   
  </select>
  
  I earn
  
    <span id="salary-calculated"></span>
</form> in Revenue
</section>


              
            
!

CSS

              
                html {
  box-sizing: border-box;
}

*, *:before, *:after {
  padding: 0;
  margin: 0;
  box-sizing: inherit
}
 
body {
  font-family: "Work Sans", "Helvetica", sans-serif;
  font-size: .9em;
  line-height: 1.45;
}

.calculator {
  height: 100vh;
  padding-left: 9%;
  border-left: solid 40px #eee;
}

/* I want to make a neat (but not too flashy) gradient animation that will fill the corresponding percentage of the `calculator` element's bg on calculation. This code has hacky gradient animation keyframes, ending on a Sass map of ethnicity-to-percentage keys. 

@TODO:
JS: Add proper ethnicity class based on user's ethnicity choice to `calculator` element when salary result is calculated.
CSS: Smooth the animation out somehow? I can't do the overshooting the background size and animate the position without some crazy mathing, because I'm dealing with specific percentages instead of just a pretty gradient. Rewrite the markup so the Map appears first as we need to reference the class name as $ethnicity.

.gradient-fill {
	background-color: white;
	animation: gradient-fill .1s ease-in forwards;
}

@keyframes gradient-fill {
  0% {
    background-image: linear-gradient(
        to bottom,
        #f7f7f7 10%,
        white 10%
    );
  }
  50% {
    background-image: linear-gradient(
        to bottom,
        #f7f7f7 28%,
        white 28%
    );
  }
   
  $ethnicity: (
    latina: 54%,
    black: 63%,
    pacificislander: 62%,
    ndn: 59%,
    asian: 90%,
  );
  
  @each $ethnicity, $percentage in $ethnicity {
    100% {
      background-image: linear-gradient(
        to bottom,
        #f7f7f7 $percentage,
        white $percentage
      )
    }
  }
}
*/

.giant-letters {
  font-size: 50px;
  line-height: 2;
  letter-spacing: -1px;
  font-weight: 300;
}

.wage-gap {
  @extend .giant-letters;
  &::first-line {
    line-height: 1;
  }
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}

input, select {
  font: 300 50px "Work Sans", "Helvetica", sans-serif;
  border: 0;
  outline: none;
  color: white;
  background-color: #ee5757;
}

.salary-initial {
  position: relative;
}

input {
	-webkit-appearance: none;
  padding: 10px 10px 10px 45px;
  width: 340px;
  margin-left: 5px;
}

.input__label {
	display: inline-block;
  position: absolute;
  top: -5px;
  left: 0;
  padding: 0 0 0 20px;
	font-size: 70%;
	user-select: none;
  color: white;
}


select {
  padding: 10px 40px 10px 10px;
  display: block;
  appearance: none;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAMCAYAAACX8hZLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiB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amLwWXkmr2MtaiEiIoJFipT23kDEN4LPQ3iF9R+S4LDmsZsfvmJ3Z+ZrdiwpZVEI4YGOCLIGPZE/DvCBG549AQnRBm/5yzC8N8UGJzZnCQq8oAVerGBgKKiAI+tfAIve1MImeOYQkeDA+uaRIE5CNMDDQFRWBDMuSJIQdXDXEJXAntVNVUGahKiBW4qIBDv2PokTZEkIF1xjRCTYsvtxkkBHEokuysANO4+yZuh+zyo4y/9o/T6TPXCURevr9gbLoh8bdMEHrHSbvgIMAMLxNoWnbjKVAAAAAElFTkSuQmCC);
  background-repeat: no-repeat;
  background-position-y: center;
  background-position-x: 645px;
  margin-bottom: -10px;
}

select option {
  font-weight: 200;
}

#salary-calculated {
	border-bottom: solid 10px #ee5757;
}

.data {
  background: #222;
  color: white;
  padding: 100px 40px;
}

@media (min-width: 1285px) {
  .calculator, .data {
    display: inline-block;
  }
  
  .calculator {
    float: left;
    width: 60%;
    padding-left: 2%;
  }
  
  .data {
    float: right;
    width: 40%;
    padding: 20px 40px;
  }
}

.data p, .data h1, .data table {
  width: 80%;
}

table {
  background-color: white;
  color: #333;
  margin: 0 auto 10px auto;
  border-collapse: collapse;
  
  td {
    padding: 10px;
    border-right: solid 2px rgba(0,0,0,.05);
    vertical-align: top;
    &:last-child {
      border-right: 0;
    }
  }
  
  thead tr {
    font-size: 16px;
    text-transform: uppercase;
    line-height: 1.2; 
    background-color: #ee5757;
    color: white;
  }
  /*
  tr td:not(:first-child) {
    text-align: center;
  }*/
  
  tbody tr:nth-of-type(odd) {
    background-color: #f7f7f7;
  }
  
}

h1 {
  @extend .giant-letters;
  line-height: 1.3;
  margin: 50px auto;
}

em {
  font-style: normal;
  background: #ee5757;
  color: white;
  padding: 0 10px;
}

p {
  display: block;
  margin: 10px auto;
}

a {
  position: relative;
	border-bottom: solid 2px #343434;
  color: #ee5757;
  text-decoration: none;
}

a:before {
	position: absolute;
	top: -22px;
	left: 0;
  width: 400px;
	padding: 10px;
	background: #fff;
  vertical-align: bottom;
	background-size: auto 40%;
  border-bottom: solid 4px #ee5757;
  box-shadow: 0 0 10px rgba(0,0,0,.2);
	color: #404d5b;
	content: attr(href);
	white-space: pre-wrap;
	word-break: break-all;
	line-height: 1.2;
	opacity: 0;
	transition: opacity 0.15s, color 0.15s, transform 0.15s, background-position 0.05s;
	transform: scale(0.5);
	pointer-events: auto;
}	

a:hover:before,
a:focus:before {
	background-position: 1em 50%;
	opacity: 1;
	transform: scale(1) translateY(-75%);
}
              
            
!

JS

              
                /*
http://www.javascript-coder.com/javascript-form/javascript-calculator-script.phtml

source is shared under the terms of LGPL 3 www.gnu.org/licenses/lgpl.html
*/

//this is an associative array! we are defining the values from the keys (the dropdown options) to use in the function.
var woman_percentage = new Array();
woman_percentage["autotrader"] = 1.54;
woman_percentage["search"] = .63;
woman_percentage["social"] = .62;
woman_percentage["ndn"] = .59;
woman_percentage["asian"] = .9;

//find the percentage of a white man's earnings based on the dropdown selection of a woman's ethnicity
function getPercentage() {
  var ethnicityPercentage = 0;
  var theForm = document.forms["wage-gap"];
  var selectedEthnicity = theForm.elements["womanethnicity"];

  //set ethnicityPercentage equal to value user chose
  ethnicityPercentage = woman_percentage[selectedEthnicity.value];

  //return the percentage numeral to calculate in the final result
  return ethnicityPercentage;
}

//what to do with the salary number input
//Since the user enters numeric value directly to the text box, we don’t have keep an associative array to map to a number. We can use the parseInt() function.
function getInitialSalary() {
  //reference the id of the form
  var theForm = document.forms["wage-gap"];
  //reference the text box
  var initialSalaryAmount = theForm.elements["salary-initial"];
  var initialSalary = 0;
  //if the textbox is not blank
  if (initialSalaryAmount.value != "") {
    initialSalary = parseInt(initialSalaryAmount.value);
  }

  //return the salary $$$ to calculate in the final result
  return initialSalary;
}

function calculateTotal() {
  //get the final calculated salary by calling our function!
  //then we have to round using weird math from http://www.webdeveloper.com/forum/showthread.php?222667-How-to-round-variables-up-to-2-decimal-places
  var getCalculatedSalary = getInitialSalary() * getPercentage();
  var calculatedSalary = Math.round(getCalculatedSalary * Math.pow(10, 2)) / Math.pow(10, 2);

  //display the result
  document.getElementById('salary-calculated').innerHTML = "$" + calculatedSalary + ".";
}


/* I wanted to figure out how to include "a" or "an" gramatically before the select element, dependent on which option is selected, but that seems to be, like, crazy difficult for my skill level.

http://jsfiddle.net/adamzr/3yhFS/ 

something with that?

function properArticle() {
  var indefiniteArticle = "an";
  document.getElementById('indefinite-article')
  .innerHTML = indefiniteArticle;
}
properArticle ();
*/
              
            
!
999px

Console