I am trying to make it so when the page loads circles appear which is fine, but I need them to grow outwards, so small to big from the center not from the top left:
You can see what I have currently here: http://thomasbritton.co.uk/projects/ebrd/
Ideally, want this to be done in CSS but can use JS if it's easier/more stable.
Any ideas?
Here is my css also for the animation part:
.circle a {
border-radius: 150px;
color: #fff;
height: 0;
position: absolute;
text-decoration: none;
width: 0;
}
.circle a.grow {
-webkit-animation-name: grow;
-webkit-animation-duration: 2.2s;
-webkit-animation-timing-function: ease;
-webkit-animation-iteration-count: 1;
-webkit-animation-direction: normal;
-webkit-animation-delay: 0;
-webkit-animation-play-state: running;
-webkit-animation-fill-mode: forwards;
-moz-animation-name: grow;
-moz-animation-duration: 2.2s;
-moz-animation-timing-function: ease;
-moz-animation-iteration-count: 1;
-moz-animation-direction: normal;
-moz-animation-delay: 0;
-moz-animation-play-state: running;
-moz-animation-fill-mode: forwards;
animation-name: grow;
animation-duration: 2.2s;
animation-timing-function: ease;
animation-iteration-count: 1;
animation-direction: normal;
animation-delay: 0;
animation-play-state: running;
animation-fill-mode: forwards;
}
@-webkit-keyframes grow {
0% { -moz-transform: scale(0); }
100% { -moz-transform: scale(1); }
}
@-moz-keyframes grow {
0% { -moz-transform: scale(0); }
100% { -moz-transform: scale(1); height: 168px; width: 168px; }
}
@keyframes grow {
0% { -moz-transform: scale(0); }
100% { -moz-transform: scale(1); }
}
To do so, your animation should involve:
It's a bit of a work, but it shall do exactly what you asked.
Just in case someone is looking for working jQuery solution, here it is...
HTML
CSS
JS
And here is the demo - http://jsbin.com/esiLULEb/1/
You don't have to use Jquery or Javascript for your case, you can achieve that with pure CSS.
Do not use position property on your animated divs. That will cause you laggy animations. Instead use transform for performant animations.
Hope this helps.
Here's a crude example of what you need to do: jsfiddle.net/UxtJV/. It uses a bit of JS to add a class to animate the circle. It's
width
,height
,top
andleft
properties are animated and it is givenposition: relative
.You could try combining your animation with the translation property.
This could be another option:
as posted here...