123

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.

            
              <div class="sky">
  <div class="cloud s1"></div>
	<div class="cloud s2"></div>
	<div class="cloud s3"></div>
	<div class="cloud s4"></div>
	<div class="cloud s5"></div>
  <div class="star-wrapper">
    <div class="stars small"></div>
    <div class="stars medium"></div>
    <div class="stars large"></div>
  </div>
</div>

            
          
!
            
              .sky {
  width: 100vw;
  height: 100vh;
  position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
  .cloud {
    width: 22.5em;
    height: 7.5em;
    background: #f2f9fe;
    -moz-border-radius: 6.25em;
    -webkit-border-radius: 6.25em;
    border-radius: 6.25em;
    position: relative;
    margin: 7.5em auto 1.25em;
  }
  .cloud:after, .cloud:before{
    content: "";
    position: absolute;
    background: #f2f9fe;
    z-index: -1;
    border-radius: 50%;
  }
  .cloud:after{
    width: 7.5em;
    height: 7.5em;
    top: -3.125em;
    left: 3.125em;
  }
  .cloud:before{
    width: 11.25em;
    height: 11.25em;
    top: -5.625em;
    right: 3.125em;
  }
  .cloud.s1 {
    transform: scale(0.9, 0.9);
    animation: moveclouds 30s linear infinite;
  }
  .cloud.s2{
    left: 12.5em;
    transform: scale(0.7, 0.7);
    animation: moveclouds 50s linear infinite;
  }
  .cloud.s3{
    left: -15.625em;
    top: -12.5em;
    transform: scale(0.4, 0.4);
    animation: moveclouds 40s linear infinite;
  }
  .cloud.s4{
    left: 29.375em;
    top: -35.65em;
    transform: scale(0.5, 0.5);
    animation: moveclouds 36s linear infinite;
  }
  .cloud.s5{
    left: -38em;
    top: -38em;
    transform: scale(0.3, 0.3);
    animation: moveclouds 44s linear infinite;
  }
}
@keyframes moveclouds {
	0%{
		margin-left: 125%;
	}
	100%{
		margin-left: -125%;
	}
}

@function box-shadow($stars) {
	$bxshadow: ();
	@for $i from 1 to $stars {
		$bxshadow: append($bxshadow, (random(2000) + 0px) (random(2000) + 0px) #fff, comma);
	}
	@return unquote($bxshadow);
}

$bxshadow-large: box-shadow(300);
$bxshadow-medium: box-shadow(500);
$bxshadow-small: box-shadow(800);
.star-wrapper {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
}
.stars.large {
	height: 3px;
	width: 3px;
	background: transparent;
	box-shadow: $bxshadow-large;
	animation: blink-large 7s infinite;
}
.stars.medium {
	height: 2px;
	width: 2px;
	background: transparent;
	box-shadow: $bxshadow-medium;
	animation: blink-medium 5s infinite;
}
.stars.small {
	height: 1px;
	width: 1px;
	background: transparent;
	box-shadow: $bxshadow-small;
	animation: blink-small 3s infinite;
}

@keyframes blink-large {
	0% {
		box-shadow: $bxshadow-large;
	}	
	70% {
		$colors: '#fff', 'transparent';
		$stars: $bxshadow-large;
		@for $i from 1 to length($stars) {
			$star: set-nth(nth($stars, $i), 3, unquote(nth($colors, random(length($colors)))));
			$stars: set-nth($stars, $i, $star);
		}
		box-shadow: $stars;
	}
	100% {
		box-shadow: $bxshadow-large;
	}
}
@keyframes blink-medium {
	0% {
		box-shadow: $bxshadow-medium;
	}	
	70% {
		$colors: '#fff', 'transparent';
		$stars: $bxshadow-medium;
		@for $i from 1 to length($stars) {
			$star: set-nth(nth($stars, $i), 3, unquote(nth($colors, random(length($colors)))));
			$stars: set-nth($stars, $i, $star);
		}
		box-shadow: $stars;
	}
	100% {
		box-shadow: $bxshadow-medium;
	}
}
@keyframes blink-small {
	0% {
		box-shadow: $bxshadow-small;
	}	
	70% {
		$colors: '#fff', 'transparent';
		$stars: $bxshadow-small;
		@for $i from 1 to length($stars) {
			$star: set-nth(nth($stars, $i), 3, unquote(nth($colors, random(length($colors)))));
			$stars: set-nth($stars, $i, $star);
		}
		box-shadow: $stars;
	}
	100% {
		box-shadow: $bxshadow-small;
	}
}
            
          
!
            
              /** checks the time of day at regular intervals **/
class DayState {
  /**
   * day state initialization
   */
  constructor() {
    this.timer();
    setInterval(() => this.timer(), 60000);
  }
  /**
   * check day state
   */
  timer() {
    this.skyState();
    this.starState();
  }
  // set the skys state depending on time of day
  skyState() {
    var sky = document.querySelector('.sky');
    var time = new Date();
    var hour = time.getHours();
    if(hour >= 7 && hour < 16) {
      sky.style.background = 'linear-gradient(180deg, #2980b9, #6dd5fa)';
    } else if(hour >= 16 && hour < 18) {
      sky.style.background = 'linear-gradient(180deg, #659999, #f4791f)';
    } else {
      sky.style.background = 'radial-gradient(ellipse at bottom, rgb(9,76,114) 0%,rgb(1,41,63) 100%)';
    }
  }
  // set the stars state depending on time of day
  starState() {
    var stars = document.querySelector('.star-wrapper');
    var time = new Date();
    var hour = time.getHours();
    if(hour >= 17 || hour < 8) {
      stars.style.display = 'block';
    } else {
      stars.style.display = 'none';
    }
  }
}
/* Create new instance of DayState checker */
let clock = new DayState();
            
          
!
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