Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

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

              
            
!

CSS

              
                .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;
	}
}
              
            
!

JS

              
                /** 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

Console