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">

<head>
  <meta charset='UTF-8' />
  <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0' />
  <link rel="stylesheet" href="styles.css" type="text/css">
  <link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" type="text/css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,700" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Julius+Sans+One" rel="stylesheet">
</head>

<body>
  <section>
    <div class="loader-container">
      <div id="loader">
        <div id="shadow"></div>
        <div id="box"></div>
      </div>
    </div>
    <h1 class="greeting">
      </h3>
      <div class="time-with-icon">
        <i class="ion-android-time"></i>
        <p class="current-time"></p>
      </div>
      <div class="weather-container">
        <div class="location-with-icon">
          <img src="http://svgshare.com/i/3Sk.svg" title="pressure" alt="">
          <h2 class="location"></h2>
        </div>
        <hr>
        <p class="w-info"></p>
        <div class="icon-temp">
          <canvas class="icon" width="64" height="64"></canvas>
          <p class="test temp">&deg;</p>
        </div>
        <div class="weather-info">
          <div class="humidity-info">
            <img src="http://svgshare.com/i/3QJ.svg" title="wind speed">
            <p class="windspeed"></p>
          </div>
          <div class="humidity-info">
            <img src="http://svgshare.com/i/3Nj.svg" title="humidity">
            <p class="humidity"></p>
          </div>
          <div class="humidity-info">
            <img src="http://svgshare.com/i/3QK.svg" title="pressure" alt="">
            <p class="pressure"></p>
          </div>

        </div>
        <div class="c-or-f">
          <label class="switch">
                        <input type="checkbox">
                        <span class="slider round"></span>
                    </label>
        </div>
      </div>
      <div class="my-info">
        <h3><a href="https://codepen.io/SL0TR/" target="_blank" rel="noopener">Mohaimin</a>, 2017</h3>
        <div class="my-contact">
          <a href="https://www.linkedin.com/in/mohaimin-islam/" target="_blank" rel="noopener"><i class="ion-social-linkedin"></i></a>
          <a href="https://www.facebook.com/Mohaimin94" target="_blank" rel="noopener"><i class="ion-social-facebook"></i></a>
          <a href="https://plus.google.com/102535643689453338746" target="_blank" rel="noopener"><i class="ion-social-googleplus"></i></a>
          <a href="https://github.com/SL0TR" target="_blank" rel="noopener"><i class="ion-social-github"></i></a>
        </div>
      </div>

  </section>
  <script src="https://rawgithub.com/darkskyapp/skycons/master/skycons.js"></script>
</body>

</html>
            
          
!
            
              * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: 'Raleway', sans-serif;
  font-size: 16px;
  color: #080808;
  text-rendering: optimizeLegibility;
}
body {
  height: 100vh;
  width: 100vw;
}
section {
  height: 100%;
  width: 100%;
  background-size: cover;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}
h1 {
  font-size: 2em;
  padding-top: .5em;
  font-family: 'Julius Sans One', sans-serif;
}
.time-with-icon {
  display: flex;
  height: 10%;
  width: 10%;
  justify-content: space-around;
  align-items: center;

}
.current-time {
  margin: 1em 0;
  font-size: 1.2em;
  font-family: 'Julius Sans One', sans-serif;
  font-weight: bold;
}
.weather-container {
  height: 30rem;;
  width: 35rem;
  background: rgba(255,255,255,.45);
  border-radius: 1em;
  box-shadow: 1px 1px 15px 1px #2e2e2e;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  padding: .5em 0;
}
h2 {
  height: 5%;
}
.location-with-icon {
  display: flex;
  height: 10%;
  width: 25%;
  justify-content: space-around;
  align-items: center;
}
.ion-compass {
  font-size: 1.8em;
  color: #EB5E28;
}
.location-with-icon img {
  height: 1.5rem;
  width: 2rem;
}

.location {
  font-weight: 400;
  font-size: 1.2em;
  height: 40%;
}
.w-info {
  height: 5%;
  font-size: 2em;
  font-weight: bold;
}
.icon-temp {
  height: 43%;
  width: 90%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.icon-temp canvas {
  height: 6rem;
  width: 6rem;
  margin-left: 2em;
}
.icon-temp p {
  font-size: 10em;
  width: 60%;
  height: 80%;
  font-family: 'Julius Sans One', sans-serif;
  color : #252422;
  transition: all   .2s;
  position: relative;
  right: 5%;
}
.temp:after {
  content: "C";
  font-size: .3em;
}
.temp-f:after {
  content: "F";
  font-size: .3em;
}
.weather-info {
  height: 15%;
  width: 90%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.weather-info img {
  height: 100%;
  width: 50%;
}
.humidity-info {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  width: 33%;
  padding-right: .5em;
}
.humidity-info img {
  height: 2rem;
  width: 5rem;
  
}

.humidity-info p  {
  font-size: 1.2em;
  position: relative;
  right: 10%;
  font-weight: 500;
}
.windspeed:after {
  content: " km/h";
  font-size: .5em;
}
.humidity-info .humidity {
  position: relative;
  right: 15%;
}
.humidity::after {
  content: " %";
  font-size: .5em;
}
.pressure:after {
  content: " hPa";
  font-size: .5em;
}
.humidity-info:last-of-type {
  width: 35%;
}
.c-or-f {
  height: 15%;
  width: 90%;
  display:flex;
  justify-content: center;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 100px;
  height: 34px;
}

.switch input {display:none;}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2196F3;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 1em;
}

.slider:before {
  position: absolute;
  content: "C";
  height: 26px;
  width: 56px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: .8em;
  font-weight: bold;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
  transform: translateX(36px);
  content: "F"
}


.my-info {
  height: 15%;
  width: 30%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}
.my-info h3 {
  position: relative;
  top: 10%;
  
}
.my-info h3 a {
  text-decoration: none;
  font-size: 1.2em;
  color: #EB5E28;
}
.my-contact {
  height: 80%;
  width: 80%;
  display: flex;
  justify-content: space-around;
  align-items: center;  
}
i {
  font-size: 2em;
  cursor: pointer;
  transition: all .2s;
}
.ion-social-linkedin:hover {
  color: #007bb5;
}
.ion-social-facebook:hover {
  color: #3b5998;
}
.ion-social-googleplus:hover {
  color: #dd4b39;
}
.ion-social-github:hover {
  color: #333;
}


.loader-container {
  height: 100vh;
  width: 100vw;
  position: absolute;
  background: #6997DB;
  z-index: 999;
}

#loader {
  /* Uncomment this to make it run! */
  /*
     animation: loader 5s linear infinite; 
  */
  
  position: absolute;
  top: calc(50% - 20px);
  left: calc(50% - 20px);
}
@keyframes loader {
  0% { left: -100px }
  100% { left: 110%; }
}
#box {
  width: 50px;
  height: 50px;
  background: #fff;
  animation: animate .5s linear infinite;
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 3px;
}
@keyframes animate {
  17% { border-bottom-right-radius: 3px; }
  25% { transform: translateY(9px) rotate(22.5deg); }
  50% {
    transform: translateY(18px) scale(1,.9) rotate(45deg) ;
    border-bottom-right-radius: 40px;
  }
  75% { transform: translateY(9px) rotate(67.5deg); }
  100% { transform: translateY(0) rotate(90deg); }
} 
#shadow { 
  width: 50px;
  height: 5px;
  background: #000;
  opacity: 0.1;
  position: absolute;
  top: 59px;
  left: 0;
  border-radius: 50%;
  animation: shadow .5s linear infinite;
}
@keyframes shadow {
  50% {
    transform: scale(1.2,1);
  }
}


            
          
!
            
              
// CSS LOADER FOR THE ONLOAD
window.onload = function() {
  document.querySelector(".loader-container").style.display = "none";
};


// Get the URL in string format
function httpGetAsync(theUrl, callback) {
  var xmlHttp = new XMLHttpRequest();
  xmlHttp.onreadystatechange = function() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
      callback(xmlHttp.responseText);
  };
  xmlHttp.open("GET", theUrl, true); // true for asynchronous
  xmlHttp.send(null);
}

// Convert it into json and change DOM accordingly
function jsonMaker(b) {

  var parsedJ = JSON.parse(b);
  unixTime = parsedJ.currently.time;;
  var summary = parsedJ.currently.summary;
  temp = parsedJ.currently.temperature;
  var timeZ = parsedJ.timezone;
  var icon = parsedJ.currently.icon;
  var windSpeed = parsedJ.currently.windSpeed;
  var humidity = parsedJ.currently.humidity;
  humidity = Math.round(humidity * 100);
  var pressure = parsedJ.currently.pressure;
  pressure = Math.round(pressure);
  temp = Math.round(temp);
  skyCon(icon);
  document.querySelector(".w-info").innerHTML = summary;
  document.querySelector(".temp").innerHTML = temp + "&deg;";
  document.querySelector('.windspeed').innerHTML = windSpeed;
  document.querySelector('.humidity').innerHTML = humidity;
  document.querySelector('.pressure').innerHTML = pressure;    
}

// MAKE CHANGES TO BACKGROUND AND GREETING TITLE ACCORDING TO THE TIME!
var currentHour;
function currentDayTime() {
  var bg = document.querySelector('section');
  var greeting = document.querySelector('.greeting');
  if(currentHour >= 5  && currentHour <= 11) {
    greeting .innerHTML = "Good Morning!";
    bg.style.backgroundImage = 'url(https://images.imgbox.com/0d/cc/EixB5djm_o.jpg)';
  } else if (currentHour >= 12  && currentHour <= 16 ) {
    greeting .innerHTML = "Good Afternoon!";
    bg.style.backgroundImage = 'url(https://images.imgbox.com/40/6f/36FietMn_o.jpg)';
  } else if (currentHour >=17  && currentHour <= 19) {
    greeting .innerHTML = "Good Evening!";
    bg.style.backgroundImage = 'url(https://images.imgbox.com/30/32/SvlHZQoO_o.jpg)';
  } else if (currentHour >=20  || currentHour <= 4) {
    greeting .innerHTML = "Good Night!";
    bg.style.backgroundImage = 'url(https://images.imgbox.com/1d/27/ac0ZUJ2X_o.jpg)';
  }  

}

// Get current time from the browser and update it per second
setInterval(function() {

    var currentTime = new Date(),
        hours = currentTime.getHours(),
        minutes = currentTime.getMinutes(),
        ampm = hours > 11 ? 'PM' : 'AM';
        if (minutes < 10) {
          minutes = "0" + minutes;
        }
        
    timeNow = hours + ":" + minutes + " " + ampm;
    document.querySelector('.current-time').innerHTML = timeNow;
    currentHour = hours;
    currentDayTime();
}, 1000); 





// For ShowPosition2 
function jsonMaker2(c) {
  parsedJ2 = JSON.parse(c);
  cityName = parsedJ2.city;
  country = parsedJ2.country;
  document.querySelector('.location').innerHTML = cityName + ", " + country; 
}

// Get current location in long and lat
function getLocation() {
  if (navigator.geolocation)
    navigator.geolocation.getCurrentPosition(showPosition);
}
var lon;
var lat;
function showPosition(position) {
   lon = position.coords.latitude;
   lat = position.coords.longitude;
  httpGetAsync(
    "https://crossorigin.me/https://api.darksky.net/forecast/4180b14d0ce80e1a97ccec5c6e67ca39/" +
      lon +
      "," +
      lat +
      "?exclude=monthly,hourly,daily,minutely,flags,alerts&units=ca",
    jsonMaker
  );
  showPosition2();
}

// Using a second API for the location
function showPosition2(position) {
  httpGetAsync(
    "https://ipinfo.io/json",
    jsonMaker2
  );
}

getLocation();



// Call Skycon icons from API
function skyCon(wthr) {
  document.querySelector(".icon").setAttribute("id", wthr);
  if (wthr == "clear-day") {
    icons.set(wthr, Skycons.CLEAR_DAY);
  } else if (wthr == "clear-night") {
    icons.set(wthr, Skycons.CLEAR_NIGHT);
  } else if (wthr == "partly-cloudy-day") {
    icons.set(wthr, Skycons.PARTLY_CLOUDY_DAY);
  } else if (wthr == "partly-cloudy-night") {
    icons.set(wthr, Skycons.PARTLY_CLOUDY_NIGHT);
  } else if (wthr == "cloudy") {
    icons.set(wthr, Skycons.CLOUDY);
  } else if (wthr == "rain") {
    icons.set(wthr, Skycons.RAIN);
  } else if (wthr == "sleet") {
    icons.set(wthr, Skycons.SLEET);
  } else if (wthr == "snow") {
    icons.set(wthr, Skycons.SNOW);
  } else if (wthr == "wind") {
    icons.set(wthr, Skycons.WIND);
  } else if (wthr == "fog") {
    icons.set(wthr, Skycons.FOG);
  }
}

// Toggle C to F 
document.querySelector(".slider").onclick = function() {
    var tempClass = document.querySelector('.test');
    tempClass.classList.toggle("temp");
    tempClass.classList.toggle('temp-f');
    tempF = temp * (9/5) + 32;
    tempF = Math.floor(tempF);
    if (tempClass.classList.contains('temp-f')) {      
      tempClass.innerHTML = tempF + "&deg;";
    } else {
      tempClass.innerHTML = temp + "&deg;";
    }    
};

// SKYCONS!!
var icons = new Skycons({ color: "#EB5E28" });

icons.set("clear-day", Skycons.CLEAR_DAY);
icons.set("clear-night", Skycons.CLEAR_NIGHT);
icons.set("partly-cloudy-day", Skycons.PARTLY_CLOUDY_DAY);
icons.set("partly-cloudy-night", Skycons.PARTLY_CLOUDY_NIGHT);
icons.set("cloudy", Skycons.CLOUDY);
icons.set("rain", Skycons.RAIN);
icons.set("sleet", Skycons.SLEET);
icons.set("snow", Skycons.SNOW);
icons.set("wind", Skycons.WIND);
icons.set("fog", Skycons.FOG);

icons.play();



            
          
!
999px
🕑 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.

Console