Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <div class="universe" id="universe">
</div>
              
            
!

CSS

              
                
body, html{
  margin: 0;
  padding:0;
  display:block;
  width:100%;
  height:100%;
}

.universe {
  position:relative;
  width:100%;
  height:100%;
  background-color: #000;
  overflow: hidden;
  z-index:-1;
}
.blokje {
  position:relative;
  display:inline-block;
 /* box-shadow: 0em 0em 1.8em; */
  left: 0%;
  top: 0%;
  padding: 10% 10% 0% 0%;
  opacity:1;
  margin: 0% 0% 0% 0%;
  margin-top: -0.28%;
  color: transparent;
  background-color:green;
  opacity:0;
}

.blokje2 {
  position:relative;
  display:inline-block;
  background-color: #FFEC47;
  left: 0%;
  top: 0%;
  padding: 8% 8% 0% 0%;
  opacity:1;
  margin: 1% 1% 1% 1%;
  border-radius: 50% 50%;
  box-sizing: border-box;
  opacity:0;

}
.blokje3 {
  position:relative;
  display:inline-block;
  left: 0%;
  top: 0%;
  padding: 8% 8% 0% 0%;
  opacity:1;
  margin: 1% 1% 1% 1%;
  box-sizing: border-box;
  opacity:0;

}

svg {
  position:absolute;
  width: 99%;
  height: 99%;
  margin:-82% 1% 1% 1%;
  fill:red;
}
@media only screen (max-width: 820px){
 
.blokje {
    margin-top: -15%;
  };
 
}
              
            
!

JS

              
                
// 2019 Made by Niels Lohmann feel free to copy and use for whatever <3

var itemOne = document.createElement('div');
var itemTwo = document.createElement('div');
var itemThree = document.createElement('div');


itemOne.setAttribute('class', 'blokje');
itemTwo.setAttribute('class', 'blokje2');
itemThree.setAttribute('class', 'blokje3');
itemThree.setAttribute('id', 'blokje3');


var windowWidth = window.innerWidth;


if (windowWidth <= 810) {
  var amount = 400;
} else {
  var amount = 100;
}

// Randomize the order in which the elements are created
for (i = 0; i < amount; i++) { 
  
let picnumber = Math.floor((Math.random() * 4) + 1);

if (picnumber == 1){
document.getElementById('universe').appendChild(itemOne.cloneNode());
} else if (picnumber == 2) {   document.getElementById('universe').appendChild(itemTwo.cloneNode());
} else if (picnumber == 3) {
  document.getElementById('universe').appendChild(itemThree.cloneNode());
} else {
  
}
}
 

var boxes = document.querySelectorAll(".blokje, .blokje2, .blokje3");
//--------------------------------------//

//create a group of colors that can be picked randomly

// var colorsOne = ['#FFF275', 'red', 'green', 'blue'];
// var colorsTwo = ['#E15554', '#fff', '#FF55EE'];

// function selectingOne(){  
// return colorsOne[Math.floor((Math.random() * 4) + 1)];
// };
// function selectingTwo(){  
// return colorsOne[Math.floor((Math.random() * 4) + 1)];
// };
// // the values need to be cloned else gsap will animatie all the colors in the array for some reason..
// var clonedValueOne = selectingOne();

// var clonedValueTwo = selectingTwo();
//--------------------------------------//


// This function gets called at the bottom of the code
function randomNumber1(){  

  for (i = 0; i < boxes.length; i++) {
    
    
  TweenMax.to(boxes[i], randomNumber(1, 3), {
    opacity:1,
      rotationX: "+=" + randomNumber(0.5, 1.5) * 50,
      rotationY: "+=" + randomNumber(0.5, 1.5) * 50,
    rotationZ: "+=" + randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5) * 50,
      delay:  randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5),
      ease:Linear.easeOut,
    onComplete:function() {
    TweenLite.delayedCall(5, randomNumber2);}
    });
      function randomNumber(min, max) {
      return Math.random() * (max - min) + min;
      }
    
    
  }
}

function randomNumber2(){
  for (i = 0; i < boxes.length; i++) {
  TweenMax.to(boxes[i], randomNumber(1, 3), {
    opacity:0,
    //rotationZ: randomNumber(0.5, 1.5) * 100,
    yoyo: true,
    delay: 1 * randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5) * randomNumber(0.5, 1.5),
    ease:Linear.easeNone,
 // call:selectingTwo(),
 //    color:clonedValueTwo,
 //     backgroundColor: clonedValueTwo,
    onComplete:function() {
    TweenLite.delayedCall(5, randomNumber1);}
    });
    
      function randomNumber(min, max) {
      return Math.random() * (max - min) + min;
      }
  }
}

// start animation
randomNumber1();

// add an svg to all divs of one class
var triangleShape = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 2 1"><g><path class="triangle-path" d="M0,0 l2,0 l-1,0.8 z" /></g></svg>';
for (i = 0; i < boxes.length; i++) {
const root = document.querySelectorAll('.blokje3')
root[i].insertAdjacentHTML('beforeend', triangleShape);};
              
            
!
999px

Console