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.

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 id="circle-nav">
  <div class="title">
    <h1><span class="highlight">Bubble Gum Pop<span></h1>
  </div>
  <div class="startBtn">
    <button id="startGame">Make Bubbles</button></div>
</div>

<div id="circle-canvas"></div>


            
          
!

CSS

            
              
@import url('https://fonts.googleapis.com/css?family=IBM+Plex+Mono:500');

$body: 'IBM Plex Mono', monospace;


body {
  margin: 0;
  font-family: $body;
}

.circle {
  border-radius: 100%;
  position: absolute;
  opacity: .8;
}

.circle, button {
    cursor: pointer;
}

#circle-canvas {
  position: relative;
  height: 100vw;
  max-width: 100%;
}

#circle-nav {
  height: 80px;
  background: #fff;
  display: flex;
  padding: 1em;
  justify-content: space-between;
  
  .title {
      h1 {
      margin: 0;
      font-weight: 500;
      border-bottom: 3px solid #f6d3dd; 
    }  
  }

  
.startBtn {
    #startGame {
      border: none;
      background: #D62F61;
      color: #fff;
      text-align: center;
      padding: 1em;
      font-family: $body;
      font-weight: 500;
      font-size: 16px;
      }  
  }  
}

            
          
!

JS

            
              
// array of colors
var colorsArray = [
  '#EA3E94', 
  '#D62F61',
  '#782464',
  '#1E53A2',
  '#39BFBD',
  '#139275',
  '#FED02F'
];

// choose random color from array
function randomColor() {
  var color = colorsArray[Math.floor(Math.random() * colorsArray.length)];
    return color;
}

// generate random height and width
function randomSize() {
  var max = 250;
  var min = 40;
  var size = Math.floor(Math.random() * max) + min + 'px';   
  return size;
}

// generate random location
function randomLocation() {
  var location = Math.floor(Math.random() * 100) + 1 + '%';
  return location;
}

randomLocation();



var body = document.querySelector('body');

var canvas = document.getElementById('circle-canvas');

var start = document.getElementById('startGame');
// add click event
start.addEventListener('click', function(){

  generateCircles();
  
  // but should say reset game after click
  // make this sticky
  
}, false);



// generate circles

function generateCircles() {
  
  var numOfCircles = 100;
  var circles = [];

  for ( var i = 0; i <= numOfCircles; i++ ) {
    var background = randomColor();
    var size = randomSize();
    var createCircle = document.createElement('div');
    
    circles[i] = createCircle;
    
    // circle attributes 
    circles[i].setAttribute('class', 'circle');
    circles[i].setAttribute('data-circle', i);
    
    // circle styles
    circles[i].style.backgroundColor = background;  
    circles[i].style.height = size;
    circles[i].style.width = size;
    circles[i].style.top = randomLocation();
    circles[i].style.right = randomLocation();
    circles[i].style.bottom = randomLocation();
    circles[i].style.left = randomLocation();

    
    
     // append to body document
    canvas.appendChild(circles[i]);
 
  }
}

// create helper function to set attributes


// remove circle on click
// circle.addEventListener("click", function(event) {
//   event.target.remove();  
//   body.appendChild(createCircle);
// }, false);
            
          
!
999px

Console