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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  <link href="https://fonts.googleapis.com/css?family=BioRhyme" rel="stylesheet">
  <div class="container text-center card card1">
    <h1 id="searchTool">Search your city</h1>
      <form action="" class="form-inline justify-content-center">
        <div class="form-group">
          <input class="form-control mr-2" id="form" type="text">
          <button id="cityBtn" class="btn">Submit</button>
      <div id="dataOutput">
        <h3 id="city"></h3>
        <h1 id="description"></h1>
        <h1 id="text"></h1>
        <h1 id="icon"></h1>
        <h1 id="errorMsg"></h1>
        <h1 id="tempButton"></h1>
      <div id="dataSun">
        <p id="sunrise"></p>
        <p id="sunset"></p>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  <script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.js"></script>
              body {
  background: linear-gradient(to right, #FFFFFF, #ECE9E6);

.card1 {
  margin: 0 auto;
  padding-top: 20px;
  padding-bottom: 20px;
  margin-top: 40px;
  margin-bottom: 30px;
  max-width: 440px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
  background: #edebe1;

.card2 {
  padding-top: 20px;
  margin: 20px 15px 20px 15px;
  width: cover;
  box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
  background: #f9f8ef;

.card3 {
  padding-top: 20px;
  margin: 10px 15px 20px 15px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
  background: #f9f8ef;

img {
  width: 70px;
  height: 70px;

h1 {
  font-family: 'BioRhyme', serif;
  font-size: 30px;
  font-weight: bold;

h2 {
  font-family: 'BioRhyme', serif;
  font-size: 30px;
  padding-bottom: 30px;

h3 {
  font-family: 'BioRhyme', serif;
  font-size: 40px;
  color: #7a3839;
  font-weight: bolder;

p {
  font-size: 18px

.fa-exclamation-triangle {
  color: #7a3839;
  font-size: 45px;
  margin-bottom: 10px;

#tempChange {
  margin-top: -50px;

.btn {
  font-size: 16px;
  color: black;
  font-family: 'BioRhyme', cursive;
  width: 120px;
  outline: none;
	padding: 7px 15px;
  margin: 0px 2px 0px 2px;
	background: #FFF;
	border-radius: 4px;
	border: solid 1px #3a3830;
	text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2.5px 2.5px rgba(0, 0, 0, 0.2);
	transition-duration: 0.2s;
.btn:hover {
	background: #dddcc3;
  border: solid 1px #3a3830;
.btn:active {
	box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
	background: #d6d3a7;
	border: solid 1px #b5b185;

@media (max-width:500px) {
      margin: 15px 2px 20px 2px;
      margin: 15px 2px 20px 2px;
      margin-top: 10px;
      font-size: 25px;

  // Listen for form submissions by either mouse click or keydown on enter key //
  document.getElementById("cityBtn").addEventListener("click", outPutInfo);
  document.getElementById('form').onkeydown = function(e){
     if(e.keyCode == 13){
    function outPutInfo(){
      var cityInput = document.getElementById('form').value;
      if (cityInput.length == 0) {
      // Get info using the open weather map API //
        url: "https://api.openweathermap.org/data/2.5/weather?q="+cityInput+"&units=metric&id=524901&APPID=06ec9f4db57789b75ea67e6e83b8a9dd",
        type: 'GET',
        success: function(data){
          var ctemperature = Math.round(data.main.temp);
          var ftemperature = Math.round(data.main.temp * (9/5) + 32);
          var iconPic = data.weather[0].icon;
          var iconUrl = "https://openweathermap.org/img/w/"+iconPic+".png";
          var sunrise = moment.unix(data.sys.sunrise).format("hh:mma");
          var sunset = moment.unix(data.sys.sunset).format("hh:mma");
          var descriptionData = data.weather[0].description;
          var tempSwitch = true;
          // Add elements to DOM //
          document.getElementById('dataOutput').className = "card text-center card2";
          document.getElementById('dataSun').className = "card text-center card3";
          document.getElementById('city').innerHTML = data.name;
          document.getElementById('text').innerHTML = "<img src='" + iconUrl  + "'>" + ctemperature + "˚" + "c";
          document.getElementById('description').innerHTML = descriptionData;
          document.getElementById('sunrise').innerHTML = "<h1>" + "Sunrise" + " "+"<i class='far fa-sun'></i>"+"</h1>" + sunrise;
          document.getElementById('sunset').innerHTML =  "<h1>" + "Sunset" + " "+"<i class='far fa-moon'></i>"+"</h1>" + sunset;
          // Clear input, error message & toggle button from any previous query //
          document.getElementById('form').value = "";
          document.getElementById('errorMsg').innerHTML = "";
          // Create button //
          var createBtn = document.createElement("button");
          createBtn.className = "btn";
          createBtn.id = "tempChange";
          createBtn.innerHTML = "C "+"<i class='fas fa-arrows-alt-h'></i>"+" F";
          // Create toggle feature on button to switch between celsuis & fahrenheit //
          document.getElementById('tempChange').addEventListener('click', function(){
            if (tempSwitch == true) {
              document.getElementById('text').innerHTML = "<img src='" + iconUrl  + "'>" + ctemperature + "˚" + "c";
              tempSwitch = false;
            } else {
              document.getElementById('text').innerHTML = "<img src='" + iconUrl  + "'>" + ftemperature + "˚" + "f";
              tempSwitch = true;
          // Function that creates an error message if search query was bad //
        error: function(data) {
          document.getElementById('city').innerHTML = "";
          document.getElementById('text').innerHTML = "";
          document.getElementById('icon').innerHTML = "";
          document.getElementById('description').innerHTML = "";
          document.getElementById('sunrise').innerHTML = "";
          document.getElementById('sunset').innerHTML = "";
          document.getElementById('dataSun').className = "";
          document.getElementById('errorMsg').innerHTML = "<i class='fas fa-exclamation-triangle'></i>" + "<br>"+"<h2>"+ "That city doesn't exist"+ "</h2>";

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.