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

            
              <!--

HTML generated by JS

Use the cursor to pop the bubbles!

Adjust the 'bubbliness' and motion resistance under JS 'Controls' 

-->
            
          
!

CSS

            
              
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
background: rgb(65,208,252);
background: -moz-linear-gradient(top,  rgba(65,208,252,1) 0%, rgba(7,118,255,1) 100%);
background: -webkit-linear-gradient(top,  rgba(65,208,252,1) 0%,rgba(7,118,255,1) 100%);
background: linear-gradient(to bottom,  rgba(65,208,252,1) 0%,rgba(7,118,255,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#41d0fc', endColorstr='#0776ff',GradientType=0 );
overflow: hidden;
}
.layer {
position: absolute;
top: 0 ;
left: 0;
width: 100%;
height: 100%;	
pointer-events: none;
}
.layer1 {
opacity: 0.3;
}
.layer2 {
opacity: 0.5;
}
.layer3 {
opacity: 0.6;
}
.layer4 {
opacity: 1;
}
.bubble {
position: absolute;
background: -moz-radial-gradient(center, ellipse cover,  rgba(255,255,255,0) 0%, rgba(255,255,255,0) 40%, rgba(255,255,255,1) 100%);
background: -webkit-radial-gradient(center, ellipse cover,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 40%,rgba(255,255,255,1) 100%);
background: radial-gradient(ellipse at center,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 40%,rgba(255,255,255,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=1 );
border-radius: 50%;	
pointer-events: auto;
}
.bubble:after {
content: "";
position: absolute;
background: -moz-radial-gradient(center, ellipse cover,  rgba(255,255,255,1) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0) 100%);
background: -webkit-radial-gradient(center, ellipse cover,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 50%,rgba(255,255,255,0) 100%);
background: radial-gradient(ellipse at center,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 50%,rgba(255,255,255,0) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff',GradientType=1 );
width: 60%;
height: 60%;
top: 5%;
right: 5%;
border-radius: 50%;	
transform: rotateY(30deg) rotateX(30deg);
opacity: 0.8;
}
.bubble-xs {
width: 24px;
height: 24px;
margin-top: -12px;	
margin-left: -12px;	
}
.bubble-sm {
width: 40px;
height: 40px;	
margin-top: -20px;	
margin-left: -20px;	
}
.bubble-md {
width: 70px;
height: 70px;	
margin-top: -35px;	
margin-left: -35px;	
}
.bubble-lg {
width: 100px;
height: 100px;	
margin-top: -50px;	
margin-left: -50px;	
}

.bubble-wobble {
-webkit-animation: bubbleWobble 0.5s ease;
-moz-animation: bubbleWobble 0.5s ease;
animation: bubbleWobble 0.5s ease;
background: -moz-radial-gradient(center, ellipse cover,  rgba(255,255,255,0) 0%, rgba(255,255,255,0) 30%, rgba(255,255,255,1) 100%);
background: -webkit-radial-gradient(center, ellipse cover,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 30%,rgba(255,255,255,1) 100%);
background: radial-gradient(ellipse at center,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 30%,rgba(255,255,255,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=1 );
}
@-webkit-keyframes bubbleWobble {
0% {
-webkit-transform: scale(1);
}
20% {
-webkit-transform: scale(0.8);
}
40% {
-webkit-transform: scale(1.1);
}
60% {
-webkit-transform: scale(0.95);
} 
80% {
-webkit-transform: scale(1.03);
} 
100% {
-webkit-transform: scale(1);
} 
}
@-moz-keyframes bubbleWobble {
0% {
-moz-transform: scale(1);
}
20% {
-moz-transform: scale(0.8);
}
40% {
-moz-transform: scale(1.1);
}
60% {
-moz-transform: scale(0.95);
} 
80% {
-moz-transform: scale(1.03);
} 
100% {
-moz-transform: scale(1);
} 
}
@keyframes bubbleWobble {
0% {
transform: scale(1);
}
20% {
transform: scale(0.8);
}
40% {
transform: scale(1.1);
}
60% {
transform: scale(0.95);
} 
80% {
transform: scale(1.03);
} 
100% {
transform: scale(1);
} 
}

.bubble-pop {
-webkit-animation: bubblePop 0.4s ease;
-moz-animation: bubblePop 0.4s ease;
animation: bubblePop 0.4s ease;
opacity: 0;
}
@-webkit-keyframes bubblePop {
0% {
-webkit-transform: scale(1);
opacity: 1;
}
20% {
-webkit-transform: scale(0);
opacity: 0.6;
}
100% {
-webkit-transform: scale(0.5);
opacity: 0;
}
}
@-moz-keyframes bubblePop {
0% {
-moz-transform: scale(1);
opacity: 1;
}
20% {
-moz-transform: scale(0);
opacity: 0.6;
}
100% {
-moz-transform: scale(0.5);
opacity: 0;
}
}
@keyframes bubblePop {
0% {
transform: scale(1);
opacity: 1;
}
20% {
transform: scale(0);
opacity: 0.6;
}
100% {
transform: scale(0.5);
opacity: 0;
}
}
            
          
!

JS

            
              
// CONTROLS
var bubbliness = 8; // Recommended between 1 and 10
var motionResistance = 3; // Recommended between 1 and 10


// Create layers
$('<div />', { 'class': 'layer layer1'  }).appendTo('body');
$('<div />', { 'class': 'layer layer2'  }).appendTo('body');
$('<div />', { 'class': 'layer layer3'  }).appendTo('body');
$('<div />', { 'class': 'layer layer4'  }).appendTo('body');

// Create bubbles
var xsBubbles = bubbliness*7.5; 
var smBubbles = bubbliness*5; 
var mdBubbles = bubbliness*3; 
var lgBubbles = bubbliness*2; 

// Fill layer 1
for(var i = 0; i < xsBubbles; i++) {
	var topPos = (Math.random() * 100) + '%';
	var leftPos = (Math.random() * 100) + '%';
	$('<div />', { 'class': 'bubble bubble-xs' }).appendTo('.layer1').css("top", topPos).css("left", leftPos);
}
// Fill layer 2
for(var i = 0; i < smBubbles; i++) {
	var topPos = (Math.random() * 100) + '%';
	var leftPos = (Math.random() * 100) + '%';
	$('<div />', { 'class': 'bubble bubble-sm' }).appendTo('.layer2').css("top", topPos).css("left", leftPos);
}
// Fill layer 3
for(var i = 0; i < mdBubbles; i++) {
	var topPos = (Math.random() * 100) + '%';
	var leftPos = (Math.random() * 100) + '%';
	$('<div />', { 'class': 'bubble bubble-md' }).appendTo('.layer3').css("top", topPos).css("left", leftPos);
}
// Fill layer 4
for(var i = 0; i < lgBubbles; i++) {
	var topPos = (Math.random() * 100) + '%';
	var leftPos = (Math.random() * 100) + '%';
	$('<div />', { 'class': 'bubble bubble-lg' }).appendTo('.layer4').css("top", topPos).css("left", leftPos);
}

motionResistance = motionResistance *= -1; // Reverse direction


// Mouse-parallax function
var windowWidth = $(window).width();
if( windowWidth > 1024 ) {
  
  $(window).mousemove(function(event){

    // Get centre of layer
    var centerX = $(window).width() / 2;
    var centerY = $(window).height() / 2;

    // Get mouse coordinates
    var mouseX = event.clientX;
    var mouseY = event.clientY;

    var layer1X = (mouseX - centerX) / (motionResistance/0.2);
    var layer1Y = (mouseY - centerY) / (motionResistance/0.2);


    var layer2X = (mouseX - centerX) / (motionResistance/0.3);
    var layer2Y = (mouseY - centerY) / (motionResistance/0.3);

    var layer3X = (mouseX - centerX) / (motionResistance/0.5);
    var layer3Y = (mouseY - centerY) / (motionResistance/0.5);

    var layer4X = (mouseX - centerX) / (motionResistance/0.75);
    var layer4Y = (mouseY - centerY) / (motionResistance/0.75);

    $('.layer1').css('left', layer1X).css('top', layer1Y);
    $('.layer2').css('left', layer2X).css('top', layer2Y);
    $('.layer3').css('left', layer3X).css('top', layer3Y);
    $('.layer4').css('left', layer4X).css('top', layer4Y);

  });
  
} // end if


// Pop function
if( windowWidth > 1024 ) { // Desktop
	
	$('.bubble').mouseover( function() {
		if ( $(this).hasClass('bubble-wobble') ) {
			var thisBubble = $(this);
			thisBubble.addClass('bubble-pop');
			setTimeout( function() {
				thisBubble.hide();
			}, 500);
		} else {
			$(this).addClass('bubble-wobble');
		}
	});
	
} else { // iPad and smaller
	
	$('.bubble').click( function() {
		var thisBubble = $(this);
		thisBubble.addClass('bubble-pop');
		setTimeout( function() {
			thisBubble.hide();
		}, 500);
	});
}
            
          
!
999px

Console