cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


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.

              <h1> Local Weather </h1>
	<div id="buttons">
	<button id="celButton">Celsius</button>
	<button id="farButton">Fahrenheit</button>

	<div id="mainDisplay" class="celsius">

		<div id="location">

		<div id="tempDisplay">
		<div id="condition">
		<div id="icon">
		<div id="description">
		<div id="wind">

		<div id="humid">

              $primary-color: #00cccc;
$dark-primary-color: darken($primary-color, 20%);
$secondary-color: #39ac39;
$main-text-color: #404040;

@mixin radial-gradient($from, $to) {
    background: -moz-radial-gradient(center, circle cover, $from 0%, $to 100%);
    background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, $from), color-stop(100%, $to));
    background: -webkit-radial-gradient(center, circle cover, $from 0%, $to 100%);
    background: -o-radial-gradient(center, circle cover, $from 0%, $to 100%);
    background: -ms-radial-gradient(center, circle cover, $from 0%, $to 100%);
    background: radial-gradient(center, circle cover, $from 0%, $to 100%);
    background-color: $from;

	font-family: "Arial";
	@include radial-gradient($primary-color, $secondary-color);
	color: $main-text-color;
	text-align: center;

	margin: 10px;
	button {
		background: $secondary-color;
		color: $main-text-color;
		border: none;
		box-shadow: 10px 5px 5px $dark-primary-color;

#location, #tempDisplay{
	margin: 8px;

#description {
	font-style: italic;
              //get location
function success(pos) {
	  var crd = pos.coords;
	  var lat =crd.latitude;
	  var lon =crd.longitude;
	  console.log('Your current position is:');
	  console.log('Latitude : ' +lat);
	  console.log('Longitude: ' +lon);

	  //Weather API Call
		$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&appid=e4e1425994f5fa474cdd4b36231633c9", function(data){
	  	//convert tempatures from K and round
	  	var tempC = ((data.main.temp)-273.15).toFixed(1);
	  	var tempF = ((data.main.temp)*(9/5)-459.67).toFixed(1);

	  	//convert windspeed
	  	var windSpeedMetric = data.wind.speed + " m/s";
	  	//need to convert to imperial 
	  	var windSpeedImperial = ((data.wind.speed)*2.2369).toFixed(1) + "mph";

		//Display Conditons (Celsius is default)

		function unitsDisplay(){
				$('#wind').html("<p> Wind Speed: " + windSpeedMetric +"</p>");
				console.log("display in celsius")

				$('#wind').html("<p> Wind Speed: " + windSpeedImperial +"</p>");
					console.log("display in fahrenheit")

			//toogle between imperial and metric 
				$("#mainDisplay").removeClass("celsius fahrenheit").addClass("celsius");
				$("#mainDisplay").removeClass("celsius fahrenheit").addClass("fahrenheit");

		  	$('#location').html(data.name +", "+ data.sys.country);
		  	$('#icon').html("<img src=http://openweathermap.org/img/w/" + data.weather[0].icon+".png>")
		  	$('#humid').html("<p> Humidity: " + data.main.humidity +"% </p>");

	function error(err) {
	  console.warn('ERROR(' + err.code + '): ' + err.message);

navigator.geolocation.getCurrentPosition(success, error);


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................