Bouncy Ball CSS



Bouncy Ball CSS




 <div class="ball-wrapper">
    <div class="ball"></div>
    <div class="ball-shadow"></div>
</div>                    
                  
                



 body { background-color: #DDDDDD; font: 30px sans-serif; height: 350px;}


.ball-wrapper {
    position: fixed;
    width: 120px;
    height: 300px;
    margin-left: -60px;
    left: 50%;
    top: 20%;
}

.ball {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 70px;
    background: -webkit-linear-gradient(top,  rgba(187,187,187,1) 0%,rgba(119,119,119,1) 99%);
    background: -moz-linear-gradient(top,  rgba(187,187,187,1) 0%,rgba(119,119,119,1) 99%);
    background: linear-gradient(top,  rgba(187,187,187,1) 0%,rgba(119,119,119,1) 99%);
    box-shadow: inset 0 -5px 15px rgba(255,255,255,0.4), inset -2px -1px 40px rgba(0,0,0,0.4), 0 0 1px #000;
    -webkit-animation: jump 1s infinite;
    -moz-animation: jump 1s infinite;
    animation: jump 1s infinite;
}

.ball::after {
    content: "";
    position: absolute;
    width: 60px;
    height: 30px;
    border-radius: 40px / 20px;
    left: 30px;
    top: 10px;
    background: -webkit-linear-gradient(top,  rgba(232,232,232,1) 0%,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%);
    background: -moz-linear-gradient(top,  rgba(232,232,232,1) 0%,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%);
    background: linear-gradient(top,  rgba(232,232,232,1) 0%,rgba(232,232,232,1) 1%,rgba(255,255,255,0) 100%);
}

.ball-shadow {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 50px;
    height: 65px;
    border-radius: 30px / 40px;
    margin-left: -25px;
    background: rgba(20, 20, 20, 0.1);
    box-shadow: 0px 0 20px 35px rgba(20,20,20,.1);
    -webkit-transform: scaleY(0.3);
    -moz-transform: scaleY(0.3);
    transform: scaleY(0.3);
    -webkit-animation: shrink 1s infinite;
    -moz-animation: shrink 1s infinite;
    animation: shrink 1s infinite;
}

/**
 *	animation
 */

@-webkit-keyframes jump {
    0% {
	top: 0;
	-webkit-animation-timing-function: ease-in;
    }
    40% {}
    50% {
	top: 140px;
	height: 120px;
	-webkit-animtion-timing-function: ease-out;
    }
    55% {
	top: 160px;
	height: 100px;
	border-radius: 70px/60px;
	-webkit-animation-timing-function: ease-in;
    }
    65% {
	top: 110px;
	height: 120px;
	border-radius: 50%;
	-webkit-animation-timing-function: ease-out;
    }
    95% {
	top: 0;
	-webkit-animation-timing-function: ease-in;
    }
    100% {
	top: 0;
	-webkit-animation-timing-function: ease-in;
    }
}

@-moz-keyframes jump {
    0% {
	top: 0;
	-moz-animation-timing-function: ease-in;
    }
    40% {}
    50% {
	top: 140px;
	height: 120px;
	-moz-animtion-timing-function: ease-out;
    }
    55% {
	top: 160px;
	height: 100px;
	border-radius: 70px/60px;
	-moz-animation-timing-function: ease-in;
    }
    65% {
	top: 110px;
	height: 120px;
	border-radius: 50%;
	-moz-animation-timing-function: ease-out;
    }
    95% {
	top: 0;
	-moz-animation-timing-function: ease-in;
    }
    100% {
	top: 0;
	-moz-animation-timing-function: ease-in;
    }
}


@-webkit-keyframes shrink {
    0% {
	bottom: 0;
	margin-left: -30px;
	width: 60px;
	height: 75px;
	background: rgba(20, 20, 20, .1);
	box-shadow: 0px 0 20px 35px rgba(20,20,20,.1);
	border-radius: 30px / 40px;
	-webkit-animation-timing-function: ease-in;
    }
    50% {
	bottom: 30px;
	margin-left: -10px;
	width: 20px;
	height: 5px;
	background: rgba(20, 20, 20, .3);
	box-shadow: 0px 0 20px 35px rgba(20,20,20,.3);
	border-radius: 20px / 20px;
	-webkit-animation-timing-function: ease-out;
    }
    100% {
	bottom: 0;
	margin-left: -30px;
	width: 60px;
	height: 75px;
	background: rgba(20, 20, 20, .1);
	box-shadow: 0px 0 20px 35px rgba(20,20,20,.1);
	border-radius: 30px / 40px;
	-webkit-animation-timing-function: ease-in;
    }
}
@-moz-keyframes shrink {
    0% {
	bottom: 0;
	margin-left: -30px;
	width: 60px;
	height: 75px;
	background: rgba(20, 20, 20, .1);
	box-shadow: 0px 0 20px 35px rgba(20,20,20,.1);
	border-radius: 30px / 40px;
	-moz-animation-timing-function: ease-in;
    }
    50% {
	bottom: 30px;
	margin-left: -10px;
	width: 20px;
	height: 5px;
	background: rgba(20, 20, 20, .3);
	box-shadow: 0px 0 20px 35px rgba(20,20,20,.3);
	border-radius: 20px / 20px;
	-moz-animation-timing-function: ease-out;
    }
    100% {
	bottom: 0;
	margin-left: -30px;
	width: 60px;
	height: 75px;
	background: rgba(20, 20, 20, .1);
	box-shadow: 0px 0 20px 35px rgba(20,20,20,.1);
	border-radius: 30px / 40px;
	-moz-animation-timing-function: ease-in;
    }
}