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

              
                <h1>Construction Materials Calculator</h1>
<p>This calculator will round up in 1/4 cubic yard increments:</p>
<form name="volcalc">
	<fieldset>
	    <legend>Enter your dimensions</legend>
	    <label class="field_name">Enter Length (Ft)</label>
	    <input name="length" class="field" onkeyup="calc();" type="text" />
	    <br /><br />
	    <label class="field_name">Enter Width (Ft)</label>
	    <input name="width" class="field" onkeyup="calc();" type="text" />
	    <br /><br />
	    <label class="field_name">Enter Depth (In)</label>
	    <input name="depth" class="field" onkeyup="calc();" type="text" />
	    <br />
	</fieldset>

	<fieldset>
	    <legend>Total</legend>
	    <label class="field_name">Total yards needed</label>
	    <input name="vol" class="field_total" type="text" />
	</fieldset>

	</form>	

<h2>How to Use this Construction Materials Calculator</h2>

<p>A cubic yard is the volume of material which fits in a space one yard wide by one yard deep by one yard high. Cubic yards are used to measure materials ranging from concrete to mulch for your garden.</p>

<ul>
<li><strong>Coverage Area Length</strong> – First you need to carefully measure the length of your project's coverage area. The calculator requires this measurement to be taken in Feet (ft). Double check your measurement, then enter that number.</li>
<li><strong>Coverage Area Width</strong> – Next, enter the width of your coverage area into the calculator. Just like the length, this number also needs to be in Feet.</li>
<li><strong>Coverage Area Depth</strong> – The final number the calculator will need, is the depth. However, this number will need to be supplied in Inches (In). Enter this number into the 3rd box and your calculation will then be complete.</li>
</ul>
              
            
!

CSS

              
                body {
	background-color: #dbbd7f;
  color: #214261;
	font-family: "Poppins", sans-serif;
	font-weight: 300;
	line-height: 1.5;
	font-size: 16px;
	text-align: ;
	transition: all .3s ease;
}

h1, h2 {
  font: 700 24px/1.2 "Poppins", sans-serif;
}

fieldset{border: 1px solid #214261;}

input[type="text"] {color: #214261;font-size: 16px;
padding: 5px;}
              
            
!

JS

              
                function calc() {
		  /*info:
		    1 yard   = 3 feet  = 36 inches
		    1 foot   = 12 inches
		    N feet   = (N/3) yards
		    N inches = (N/12) feet
		    N inches = (N/36) yards
		  */

		  //get inputs
		  var l = document.volcalc.length.value; //in feet
		  var w = document.volcalc.width.value; //in feet
		  var d = document.volcalc.depth.value; //in inches

		  //convert length feet to yards
		  l = l/3;

		  //convert width feet to yards
		  w = w/3;

		  //convert depth inches to yards
		  d = d/36;

		  //calculate volume in yards
		  var v = l * w * d;

		  // round numbers up to nearest whole number
		  // var v = Math.ceil( v );

		  // round to 2 decimal places
		  // var v = Math.round( v * 100) / 100;

		  // round numbers in increments of .25
		  var v = Math.round( v * 4 ) / 4 ;

		  document.volcalc.vol.value = v; //in yards

}
              
            
!
999px

Console