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

              
                <!-- 30 "particles" are generated using Pug.js, then styled like circles and followed by a centered div with text content and a link. You could also use SVGs for unique shapes -->
body
  .particle-container
    .particles
      - var n = 0;
      while n < 30
        span.circle(class=n++)

.home-hero
  .home-hero-content
    h1.home-hero-title CSS Particles Animation
    a.button.home-hero-button(href='#') button

              
            
!

CSS

              
                /*** Particle Animation ***/
/*** Inspired by Tuts Plus https://codepen.io/tutsplus/pen/MrjYJK ***/
/*** and particles.js ***/

@import url('https://fonts.googleapis.com/css?family=Coustard:900&display=swap');

// Color Vars
$sapling: #f9ecd0;
$space: #2d363f;
$cream: #fff9e6;

body {
  margin: 0;
  font-family: 'Coustard', serif;
}
.particle-container {
  background-color: $sapling;
  position: relative;
  height: 100vh;
}

.home-hero {
  position: absolute;
  left: 50%;
  top:50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  text-align:center;
  z-index: 13;
}

h1.home-hero-title {
  color: $space ;
  font-size: 3rem;
  text-shadow: 2px 2px 6px $cream;
 }

a.button.home-hero-button {
  background-color: $space;
  color: $cream;
  text-decoration: none;
  box-shadow: 2px 2px 6px $space;
  padding: 1rem;
  border-radius: 5px;
	font-size: 1.5rem;
   
  &:hover {
    background-color: lighten($space, 10);
  }
}

.circle {
  border-radius: 50%;
  position:absolute;
  z-index: 12;
}
//use a for loop to create a unique keyframe for each element
//then apply randomized styles to them all
@for $i from 1 through 31 {
  @-webkit-keyframes particle-animation-#{$i} {
    0% {
      -webkit-transform:translate3d((random(110) * 1vw), (random(100) * 1vh), (random(400) * 1px)) rotate(random(90) + deg);
      transform:translate3d((random(110) * 1vw), (random(100) * 1vh), (random(400) * 1px)) rotate(random(90) + deg);
    }
    100% {
      -webkit-transform: translate3d((random(110) * 1vw), (random(100) * 1vh), (random(400) * 1px)) rotate(random(180) + deg);
      transform: translate3d((random(110) * 1vw), (random(100) * 1vh), (random(400) * 1px)) rotate(random(180) + deg);
		}
	}
  @keyframes particle-animation-#{$i} {
    0% {
      -webkit-transform:translate3d((random(110) * 1vw), (random(100) * 1vh), (random(110) * 1px)) rotate(random(90) + deg);
      transform:translate3d((random(110) * 1vw), (random(100) * 1vh), (random(400) * 1px)) rotate(random(90) + deg);
    }
    100% {
      -webkit-transform: translate3d((random(110) * 1vw), (random(100) * 1vh), (random(400) * 1px)) rotate(random(180) + deg);
      transform: translate3d((random(110) * 1vw), (random(100) * 1vh), (random(400) * 1px)) rotate(random(180) + deg);
		}
	}
  
  //fade in and out
	@-webkit-keyframes fade-frames {
    0% {
      opacity: 0;
    }
    25% {
      opacity: .5;
    }
    100% {
      opacity: 1;
    }
    75% {
      opacity: .5;
    }
    100% {
      opacity: 0;
    }
  }
  @keyframes fade-frames {
      0% {
        opacity: 0;
      }
      25% {
        opacity: .5;
      }
      100% {
        opacity: 1;
      }
      75% {
        opacity: .5;
      }
      100% {
        opacity: 0;
      }
    }

  //apply keyframes to children of .particles - the circles
  //and make them a random size, color, and delay
	.particles span:nth-child(#{$i}){
    -webkit-animation: particle-animation-#{$i} 10s ease-in infinite, fade-frames 10s ease-in-out infinite;
    animation: particle-animation-#{$i} 10s ease-in infinite, fade-frames 10s ease-in-out infinite;
		$size: random(100) + 5 + px;
		height: $size;
		width: $size;
    $color: random(255);
    //this will make them all a random shade of greyish
    background-color: rgb($color, $color, $color);
    -webkit-animation-delay: -$i + s;
    animation-delay: -$i + s;
    // -webkit-transform: translate3d((random(90) * 1vw), (random(90) * 1vh), (random(100) * 1px));
    // transform: translate3d((random(90) * 1vw), (random(90) * 1vh), (random(100) * 1px));
  }
}

/********* End particle Animation Styles ***********/
              
            
!

JS

              
                
              
            
!
999px

Console