CSS
.ball {
width: 50px;
height: 50px;
position: absolute;
left: 110px;
top: 100px;
background: #fcecfc; /* Old browsers */
background: -moz-linear-gradient(left, #fcecfc 0%, #fba6e1 42%, #fd89d7 59%, #a34f8f 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#fcecfc), color-stop(42%,#fba6e1), color-stop(59%,#fd89d7), color-stop(100%,#a34f8f)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #fcecfc 0%,#fba6e1 42%,#fd89d7 59%,#a34f8f 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #fcecfc 0%,#fba6e1 42%,#fd89d7 59%,#a34f8f 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #fcecfc 0%,#fba6e1 42%,#fd89d7 59%,#a34f8f 100%); /* IE10+ */
background: linear-gradient(to right, #fcecfc 0%,#fba6e1 42%,#fd89d7 59%,#a34f8f 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcecfc', endColorstr='#a34f8f',GradientType=1 ); /* IE6-9 */
border-radius: 999px;
z-index: 10;
}
button {
color: #444;
font-weight: bolder;
background: lightblue;
border-radius: 5px;
border-color: grey;
margin: 50px auto 30px;
display: block;}
.shadow {
width: 0px;
height: 0px;
position: absolute;
top: 225px;
left: 85px;
background: -moz-radial-gradient(center, ellipse cover, rgba(91,91,91,1) 0%, rgba(142,142,142,0.84) 16%, rgba(227,228,229,0) 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(91,91,91,1)), color-stop(16%,rgba(142,142,142,0.84)), color-stop(100%,rgba(227,228,229,0))); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, rgba(91,91,91,1) 0%,rgba(142,142,142,0.84) 16%,rgba(227,228,229,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, rgba(91,91,91,1) 0%,rgba(142,142,142,0.84) 16%,rgba(227,228,229,0) 100%); /* Opera 12+ */
background:...
JavaScript
$(function() {
var time = 500;
var bounces = 5;
var top_bounce = 100;
var shadow_size = 0;
function bounceDown(){
$(".ball").animate({top: 200}, time, function(){
bounceUp();
});
};
document.getElementById("number-of-bounce").innerHTML = bounces;
function bounceUp() {
$(".ball").animate({top: top_bounce}, time);
top_bounce = top_bounce + 20;
};
function shadowUp(){
$(".shadow").animate({width: 100, height: 10, left: 85, top: 245, opacity: 1}, time,
function(){
shadowDown();
});
};
function shadowDown() {
console.log(shadow_size);
$(".shadow").animate({width: shadow_size*100, height: shadow_size*10, left: 110, top: 225, opacity: 0}, time);
shadow_size += 0.2;
};
function finalDown(){
$(".ball").animate({top: 200}, time);
};
function finalShadow(){
$(".shadow").animate({width: 100, height: 10, left: 85, top: 245, opacity: 1}, time);
};
$(".button").on("click", function(){
for (var i = 0; i < bounces; i++){
setTimeout(function(){
bounceDown();
shadowUp();
}, time*2*i);
setTimeout(function(){
finalDown();
finalShadow();
}, 5000);
};
});
});