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

              
                <html>
<head>
	<title>Pace Calculator</title>
	<link rel="stylesheet" type="text/css" href="../js-pace-calculator/calculator.css">
</head>
<body>
	<h1>Running Pace Caluculator</h1>
	<h3>Type in the distance you plan to run and the time in which you'd like to run that distance to find your necessary pace.</h3>
	<p>Distance: <input type="text" placeholder="miles" id="distance"/> miles</p>
	<p>Time: <input type="text" placeholder="hours" id="hours"/> : <input type="text" placeholder="minutes" id="minutes"/> : <input type="text" placeholder="seconds" id="seconds"/></p>
	<p><button id="calculate_btn">Calculate Pace</button></p>
	<p id="pace"/>

	<script type="text/javascript" src="../js-pace-calculator/calculator.js"></script>
</body>
</html>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lato:300,400,900);

html {
	font-family:Lato;
}

body{
	margin:3em;
}

input {
	width: 60px;
}
              
            
!

JS

              
                var distanceInput = document.getElementById("distance"),
	hoursInput = document.getElementById("hours"),
	minutesInput = document.getElementById("minutes"),
	secondsInput = document.getElementById("seconds"),
	calculateBtn = document.getElementById("calculate_btn"),
	paceText = document.getElementById("pace");

calculateBtn.addEventListener("click", function() {
	var miles = parseFloat(distanceInput.value),
		hours = parseFloat(hoursInput.value),
		minutes = parseFloat(minutesInput.value),
		seconds = parseFloat(secondsInput.value);

	if(isNaN(miles)) {
		distanceInput.style.borderColor = "red";
		return;
	}
	else {
		distanceInput.style.borderColor = "initial";
	}
	if(isNaN(hours)) {
		hoursInput.style.borderColor = "red";
		return;
	}
	else {
		hoursInput.style.borderColor = "initial";
	}
	if(isNaN(minutes)) {
		minutesInput.style.borderColor = "red";
		return;
	}
	else {
		minutesInput.style.borderColor = "initial";
	}
	if(isNaN(seconds)) {
		secondsInput.style.borderColor = "red";
		return;
	}
	else {
		secondsInput.style.borderColor = "initial";
	}

	var totalMinutes = hours * 60 + minutes + seconds / 60,
		pace = totalMinutes / miles,
		paceMinutes = Math.floor(pace),
		paceSeconds = Math.round((pace - paceMinutes) * 60);

	if(paceSeconds < 10) {
		paceSeconds = "0" + paceSeconds;
	}

	paceText.textContent = "You need to run " + paceMinutes + ":" + paceSeconds + " minutes per mile.";
});
              
            
!
999px

Console