<h1>Simple circle firework</h1>
<h1>Simple circle firework</h1>
<div class = "main">
<div class="cannon"></div>
<div class = "circle"></div>
</div>
<script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300);
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300);
* {
font-family: 'Open Sans', sans-serif;
}
body {
background: #22222D;
}
h1 {
background: white;
text-align: center;
margin: 30px auto;
}
.main {
width: 500px;
height: 500px;
margin: 20px auto;
position: relative;
}
.circle {
position: absolute;
left: 232.5px;
top: 0px;
width: 25px;
height: 25px;
transition: left 0.5s ease, top 1s ease;
border-radius: 50%;
}
.cannon {
position: absolute;
background: gradient(linear, 0 0, 100% 0, from(rgba(169,3,41,1)), color-stop(0.44, rgba(143,2,34,1)), to(rgba(109,0,25,1)));
background: linear-gradient(left, rgba(169,3,41,1) 0%, rgba(143,2,34,1) 44%, rgba(109,0,25,1) 100%);
background: linear-gradient(left, rgba(169,3,41,1) 0%, rgba(143,2,34,1) 44%, rgba(109,0,25,1) 100%);
background: linear-gradient(left, rgba(169,3,41,1) 0%, rgba(143,2,34,1) 44%, rgba(109,0,25,1) 100%);
background: linear-gradient(left, rgba(169,3,41,1) 0%, rgba(143,2,34,1) 44%, rgba(109,0,25,1) 100%);
box-shadow: 0px 0px 5px black;
left: 232.5px;
top: 0px;
width: 20px;
height: 50px;
animation-name: bang_bang;
animation-duration: 0.3s;
animation-timing-function: ease;
animation-iteration-count: infinite;
}
@keyframes bang_bang {
from {transform: scale(1);}
50% {transform: scale(1.5);}
to {transform: scale(1);}
}
var colors = ["#F88431","#F6BA35","#EDD43A","#89DC28", "#FF3399", " #FF0066"]; // you can add your own colors
var colors = ["#F88431","#F6BA35","#EDD43A","#89DC28", "#FF3399", " #FF0066"]; // you can add your own colors
var col_length = colors.length;
var number_of_circles = 200; // you can change number of circles;
var i = 0;
function create_random_line() {
$('.main').append('<div class = "circle"></div>');
if(i<number_of_circles-1)
{
setTimeout(function(){
var getRandomPosX = Math.random() * 475;
var getRandomPosY = Math.random() * (475 - 70) + 70;
var getRandomColor = Math.floor(Math.random() * col_length);
var getRandomScale = Math.random() * (1.8 - 0.5) + 0.5;
var getRandomOpacity = Math.random() * (1 - 0.3) + 0.3;
var getRandomZIndex = Math.floor(Math.random() * 10);
console.log(getRandomZIndex)
$('.circle').eq(i).css({'left': getRandomPosX,
'top': getRandomPosY,
'transform': 'scale('+getRandomScale+')',
'background': colors[getRandomColor],
'opacity': getRandomOpacity,
'z-index': getRandomZIndex
});
create_random_line() }, 30);
i++;
}
else {
$('.cannon').fadeOut(200);
return;
}
}
create_random_line();