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

Quick-add: + add another resource

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.

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;
	position: absolute;
	width: 30px;
	
	&__is-popped {
		animation: pop .7s ease-in-out;
	}
}

@keyframes pop {
	0% {
		@include transform(scale(1));
		opacity: 1;
	}
	
	30% {
		@include transform(scale(2));
		opacity: 1;
	}
	
	100% {
		@include transform(scale(1.7));
		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