Pen Settings



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


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


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.


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.


                <div class="wrap text-center">
  <div class="weather-container hidden">
    <div class="location"></div>
    <div class="temp"></div>
    <div class="btn toggleBTN hidden">°F</div>
    <div class="weather-icon"></div>
    <div class="forecast"></div>
  <div class="btn btn-primary startBTN">Get Local Weather</div>


                body {
  min-height: 100vh;
  font-family: 'Roboto Slab', serif;
  color: #4C7974;
  padding: 10px;
  font-size: 30px;
  background-image: url("");
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;

.wrap {
  position: absolute;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;

.startBTN {
  color: #fff;
  box-shadow: 0 0 5px #999;
  padding: 10px;
  display: block;
  margin-top: 20px;
  font-size: 18px;
  letter-spacing: 3px;
  word-spacing: 5px;
  background-color: #4C7974;
  border: none;
.startBTN:hover {
  background-color: #416864;

.toggleBTN {
  border: 2px solid #4C7974;
  color: #4C7974;
  transition: 0.5s;
  padding: 0 5px;
  font-size: 18px;
.toggleBTN:hover {
  border: 2px solid #C0C0C0;
  color: #C0C0C0;
  box-shadow: 0 0 3px #999;

.location {
  font-size: 50px;

.weather-icon {
  margin-top: 10px;

.weather-container {
  background-color: rgba(255,255,255,0.75);
  padding: 20px;
  border-radius: 4px;
  box-shadow: 0 0 5px #999;
  transition: 1.4s;


                $(document).ready(function() {
  var latitude = '';
  var longitude = '';
  var fahrenheit = '';
  var celsius = '';

  $(".startBTN").on("click", function() {
    if (navigator.geolocation) {
    } else {
      $(".text").html('Geolocation is not supported by this browser.');

    function getPosition(position) {
      latitude = position.coords.latitude;
      longitude = position.coords.longitude;

    function displayData() {
      $.getJSON(getURL(), function(response) {
        fahrenheit = response.current_observation.temp_f + " °F ";
        celsius = response.current_observation.temp_c + " °C ";
        $(".weather-icon").html('<img src="' + response.current_observation.icon_url + '">');

    function getURL() {
      return '' + latitude + ',' + longitude + '.json';

  $(".toggleBTN").on("click", function(event) {
    var btn_text = $('.toggleBTN').html();
    $(this).html(btn_text == "°C" ? "°F" : "°C");
    var temp_text = $(".temp").html();
    $(".temp").html(temp_text == fahrenheit ? celsius : fahrenheit);