cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              @mixin transition($args){
  -webkit-transition: $args;
  -moz-transition: $args;
  -ms-transition: $args;
  -o-transition: $args;
  transition: $args;
}

@mixin transform($transforms) {
	-moz-transform: $transforms;
	-o-transform: $transforms;
	-ms-transform: $transforms;
	-webkit-transform: $transforms;
  transform: $transforms;
}

@mixin pop($scale) {
	-webkit-transform: scale($scale);
	-moz-transform: scale($scale);
	-ms-transform: scale($scale);
	-o-transform: scale($scale);
	transform: scale($scale);
}

$afBlue:  rgb(13,95,182);
$afBlue2: lighten($afBlue, .5);

body, html {
	text-align: center;
}

#container {
	background: $afBlue;
	display: block;
	height: 100vh;
	overflow: hidden;
	position: absolute;
	width: 100vw;
}

.bubble {
	border: 2px solid white;
	border-radius: 50%;
	cursor: pointer;
	display: block;
	height: 30px;
	//transition: all .8s ease-out;
	position: absolute;
	width: 30px;
	
	&__is-popped {
		animation: pop .7s ease-in-out;
		//border-color: rgb(167, 100 ,169);
	}
	
	&:hover {
		
		
		//@include transform(scale(3));
	}
}

@keyframes pop {
	0% {
		@include transform(scale(1));
		opacity: 1;
	}
	
	20%{
		//border-color: white;
		//background: transparent;
		//border-width: 1px;
		//opacity: 1;
	}
	
	30% {
		@include transform(scale(2));
		opacity: 1;
	}
	
	100% {
		@include transform(scale(1.7));
		//border-color: transparent;
		background: white;
		opacity: 0;
	}
}
            
          
!
            
              const numberOfBubbles = 20,
			hoverBubbleClass = 'bubble__is-popped',
			initialAnimateClass = 'fadeInUp',
			$container = document.getElementById('container'),
			windowWidth = window.innerWidth,
			windowHeight = window.innerHeight;

let delayTime = 0;

// create the bubble with the listeners
const createBubbleOnDom = ($bubble, _this) => {
	$container.appendChild($bubble);
	$bubble.addEventListener("animationend", handleBubbleRemove.bind(_this));
	$bubble.addEventListener("mouseover", handleBubbleHover.bind(_this));
	$bubble.addEventListener("mouseleave", handleBubbleOff.bind(_this));
}

// get random numbers for placement
const getRandomNumber = (min, max) => {
	return Math.floor(Math.random() * (max - min)) + min;
}

// handle the hover of bubbles
const handleBubbleHover = (e) => {
	e.target.classList.remove(initialAnimateClass);
	e.target.classList.add(hoverBubbleClass);
}

// handle the off hover of bubbles
const handleBubbleOff = (e) => {
	const newBubble = addBubble(getRandomNumber(0, windowWidth), getRandomNumber(0, windowHeight));
	createBubbleOnDom(newBubble, this);
	$container.appendChild(newBubble);
}

// removing the bubble
const handleBubbleRemove = (e) => {
	e.target.remove();
	const newBubble = addBubble(getRandomNumber(0, windowWidth), getRandomNumber(0, windowHeight));
	createBubbleOnDom(newBubble, this);
	$container.appendChild(newBubble);
}

// add bubble method
const addBubble = (x,y) => {
	const newBubble = document.createElement("DIV");
	newBubble.classList.add('bubble', 'animated', initialAnimateClass);
	newBubble.style.left=`${x}px`;
	newBubble.style.top=`${y}px`;
	return newBubble;
}

// Init the bubble page
(() => {
	const bubbleArray = [];
	// create the bubble nodes and add them to the array
	for(let i = 0; i < numberOfBubbles; i++) {
		let randomX = getRandomNumber(0, windowWidth);
		let randomY = getRandomNumber(0, windowHeight);
		bubbleArray.push(addBubble(randomX,randomY));
	}
	// get bubble nodes from array and attach to DOM
	bubbleArray.map((val,key) => {0
		setTimeout(() => {
			createBubbleOnDom(val, this);
		}, 750*key);
	})
})();
            
          
!
999px
Loading ..................

Console