I'm trying to create a wave animation with 3 layers. The animation as you can see in the snippet, doesn't seem smooth, and it seems like the waves aren't endless. Besides I can't really get to see the waves structure like in the picture.
I would to see the waves without interruption, when it comes to the end of the animation, it is clearly noticeable that the animation has ended.
[![
.w1 {
stroke: none;
fill: #b3696c;
opacity: 55%;
animation: move1 4.5s linear infinite;
}
.w2 {
stroke: none;
fill: #b3696c;
opacity: 35%;
transform: translate3d(0, 0, 0);
animation: move2 4.5s linear infinite;
}
.w3 {
stroke: none;
fill: #cf2127;
opacity: 30%;
transform: translate3d(0, 0, 0);
animation: move3 2s linear infinite;
}
#keyframes move1 {
0% {
transform: translateX(-500px) scaleX(2.5);
}
50% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(0) scaleX(2.5);
}
}
#keyframes move2 {
0% {
transform: translateX(-600px) scaleX(3);
}
50% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(0) scaleX(3);
}
}
#keyframes move3 {
0% {
transform: translateX(-800px) scaleX(4);
}
50% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(0) scaleX(4);
}
}
<div class="waveAnimation">
<svg viewBox="0 0 500 150" preserveAspectRatio="none">
<path
class="w1 waveTop"
d="M-8.74,71.55 C289.78,255.11 349.60,4.47 505.36,34.05 L500.00,150.00 L0.00,150.00 Z"
/>
<path
class="w2 waveMiddle"
d="M-23.42,125.83 C187.63,45.89 299.38,57.73 526.80,123.86 L500.00,150.00 L0.00,150.00 Z"
/>
<path
class="w3 waveBottom"
d="M-23.42,125.83 C172.96,-152.44 217.55,183.06 504.22,55.77 L500.00,150.00 L0.00,150.00 Z"
/>
</svg>
</div>
The wave animations should move smoothly, so instead of using the linear attribute, we use ease-in-out.
.w1 {
stroke: none;
fill: #b3696c;
opacity: 55%;
animation: move1 5s ease-in-out infinite;
}
.w2 {
stroke: none;
fill: #b3696c;
opacity: 35%;
transform: translate3d(0, 0, 0);
animation: move2 4s ease-in-out infinite;
}
.w3 {
stroke: none;
fill: #cf2127;
opacity: 30%;
transform: translate3d(0, 0, 0);
animation: move3 6s ease-in-out infinite;
}
#keyframes move1 {
0% {
transform: translateX(-500px) scaleX(2.5);
}
25% {
transform: translateX(-100) scaleX(2.5);
}
50% {
transform: translateX(0) scaleX(2.5);
}
75% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(-500px) scaleX(2.5);
}
}
#keyframes move2 {
0% {
transform: translateX(-600px) scaleX(3);
}
25% {
transform: translateX(-100) scaleX(2.5);
}
50% {
transform: translateX(0) scaleX(3);
}
75% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(-600px) scaleX(3);
}
}
#keyframes move3 {
0% {
transform: translateX(-800px) scaleX(3);
}
25% {
transform: translateX(-100) scaleX(2.5);
}
50% {
transform: translateX(0) scaleX(3);
}
75% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(-800px) scaleX(3);
}
}
<div class="waveAnimation">
<svg viewBox="0 0 500 150" preserveAspectRatio="none">
<path
class="w1 waveTop"
d="M-8.74,71.55 C289.78,255.11 349.60,4.47 505.36,34.05 L500.00,150.00 L0.00,150.00 Z"
/>
<path
class="w2 waveMiddle"
d="M-23.42,125.83 C187.63,45.89 299.38,57.73 526.80,123.86 L500.00,150.00 L0.00,150.00 Z"
/>
<path
class="w3 waveBottom"
d="M-23.42,125.83 C172.96,-152.44 217.55,183.06 504.22,55.77 L500.00,150.00 L0.00,150.00 Z"
/>
</svg>
</div>
Here is my solution, I hope it helps you.
.w1 {
stroke: none;
fill: #b3696c;
opacity: 55%;
animation: move1 6s linear infinite;
}
.w2 {
stroke: none;
fill: #b3696c;
opacity: 35%;
transform: translate3d(0, 0, 0);
animation: move2 6s linear infinite;
}
.w3 {
stroke: none;
fill: #cf2127;
opacity: 30%;
transform: translate3d(0, 0, 0);
animation: move3 2s linear infinite;
}
#keyframes move1 {
0% {
transform: translateX(-500px) scaleX(2.5);
}
25% {
transform: translateX(-100) scaleX(2.5);
}
50% {
transform: translateX(0) scaleX(2.5);
}
75% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(-500px) scaleX(2.5);
}
}
#keyframes move2 {
0% {
transform: translateX(-600px) scaleX(3);
}
25% {
transform: translateX(-100) scaleX(2.5);
}
50% {
transform: translateX(0) scaleX(3);
}
75% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(-600px) scaleX(3);
}
}
#keyframes move3 {
0% {
transform: translateX(-800px) scaleX(3);
}
25% {
transform: translateX(-100) scaleX(2.5);
}
50% {
transform: translateX(0) scaleX(3);
}
75% {
transform: translateX(-100) scaleX(2.5);
}
100% {
transform: translateX(-800px) scaleX(3);
}
}
<div class="waveAnimation">
<svg viewBox="0 0 500 150" preserveAspectRatio="none">
<path
class="w1 waveTop"
d="M-8.74,71.55 C289.78,255.11 349.60,4.47 505.36,34.05 L500.00,150.00 L0.00,150.00 Z"
/>
<path
class="w2 waveMiddle"
d="M-23.42,125.83 C187.63,45.89 299.38,57.73 526.80,123.86 L500.00,150.00 L0.00,150.00 Z"
/>
<path
class="w3 waveBottom"
d="M-23.42,125.83 C172.96,-152.44 217.55,183.06 504.22,55.77 L500.00,150.00 L0.00,150.00 Z"
/>
</svg>
</div>
Related
I have an SVG with animated eyes on my website. The eyes have a blink animation made with transform: scale(). When I now open Chrome and the eyes blink the path of the eyes sometimes gets blurred. It often happens when I scale the website to 90%, but it is not consistent. I also tried adding translateZ(0) and backface-visibility: hidden; but nothing helped.
Can I solve this somehow?
Since it doesn't happen consistently I don't know if this Snippet will show my problem. As an alternative, I made a JSFiddle: https://jsfiddle.net/qnwj8uLm/
.info-eyes {
animation-name: info-eyes;
animation-duration: 6s;
animation-iteration-count: infinite;
transform: scale(1) translateZ(0);
transform-origin: 0% 75%;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0) scale(1, 1);
}
.info-iris {
animation-name: info-iris;
animation-duration: 6s;
animation-iteration-count: infinite;
}
#keyframes info-eyes {
0% {transform:scale(1, 1) translateZ(0); }
96% {transform:scale(1, 1) translateZ(0); }
98% {transform:scale(1, 0.1) translateZ(0); }
100% {transform:scale(1, 1) translateZ(0); }
}
#keyframes info-iris {
0% {transform: translate(0%, 0%); opacity: 100%;; }
25% {transform: translate(0%, 8%); opacity: 100%;}
50% {transform: translate(8%, 8%); opacity: 100%;}
75% {transform: translate(8%, 8%); opacity: 100%;}
96% {transform: translate(0%, 0%); opacity: 100%;}
98% {transform: translate(0%, 0%); opacity: 0%;}
100% {transform: translate(0%, 0%); opacity: 100%;}
}
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" width="81.7" height="75.3" viewBox="0 0 81.7 75.3">
<defs>
<style>
.a {
fill: none;
}
.b {
clip-path: url(#a);
}
.h {
fill: #fff;
}
</style>
<clipPath id="a">
<rect class="a" width="81.7" height="75.3" />
</clipPath>
</defs>
<g transform="translate(40.85 37.65)">
<g class="b" transform="translate(-40.85 -37.65)">
<path class="info-eyes" d="M34.8,52.7a7,7,0,1,1-7-7,7,7,0,0,1,7,7" />
<path class="info-eyes" d="M60.7,52.7a7,7,0,1,1-7-7,7,7,0,0,1,7,7" />
<path class="h info-iris" d="M25.9,50.6c0-2-2.5-2.4-2.5,0s2.5,2,2.5,0" />
<path class="h info-iris" d="M51.6,50.6c0-2-2.5-2.4-2.5,0s2.5,2,2.5,0" />
</g>
</g>
</svg>
</body>
The problem likely stems from browser optimization. There are some possible solutions, like will-change: transform, but in my browser it does not work in your example. A hackish way to force the browser to redraw is to add a transform: translateZ(0) right after scaling that is messing the figure:
.info-eyes {
animation-name: info-eyes;
animation-duration: 6s;
animation-iteration-count: infinite;
transform: scale(1) translateZ(0);
transform-origin: 0% 75%;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0) scale(1, 1);
}
.info-iris {
animation-name: info-iris;
animation-duration: 6s;
animation-iteration-count: infinite;
}
#keyframes info-eyes {
0% {transform:scale(1, 1) translateZ(0); }
96% {transform:scale(1, 1) translateZ(0); }
98% {transform:scale(1, 0.1) translateZ(0); }
98.001% {transform: translateZ(0); }
100% {transform:scale(1, 1) translateZ(0); }
}
#keyframes info-iris {
0% {transform: translate(0%, 0%); opacity: 100%;; }
25% {transform: translate(0%, 8%); opacity: 100%;}
50% {transform: translate(8%, 8%); opacity: 100%;}
75% {transform: translate(8%, 8%); opacity: 100%;}
96% {transform: translate(0%, 0%); opacity: 100%;}
98% {transform: translate(0%, 0%); opacity: 0%;}
100% {transform: translate(0%, 0%); opacity: 100%;}
}
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" width="81.7" height="75.3" viewBox="0 0 81.7 75.3">
<defs>
<style>
.a {
fill: none;
}
.b {
clip-path: url(#a);
}
.h {
fill: #fff;
}
</style>
<clipPath id="a">
<rect class="a" width="81.7" height="75.3" />
</clipPath>
</defs>
<g transform="translate(40.85 37.65)">
<g class="b" transform="translate(-40.85 -37.65)">
<path class="info-eyes" d="M34.8,52.7a7,7,0,1,1-7-7,7,7,0,0,1,7,7" />
<path class="info-eyes" d="M60.7,52.7a7,7,0,1,1-7-7,7,7,0,0,1,7,7" />
<path class="h info-iris" d="M25.9,50.6c0-2-2.5-2.4-2.5,0s2.5,2,2.5,0" />
<path class="h info-iris" d="M51.6,50.6c0-2-2.5-2.4-2.5,0s2.5,2,2.5,0" />
</g>
</g>
</svg>
</body>
I found a solution to my problem. I changed the blink-keyframe from transform:scale(1, 0.1) to transform:scale(1, 0.2) and now the animation works fine.
Snippet:
.info-eyes {
animation-name: info-eyes;
animation-duration: 6s;
animation-iteration-count: infinite;
transform-origin: 0% 75%;
}
.info-iris {
animation-name: info-iris;
animation-duration: 6s;
animation-iteration-count: infinite;
}
#keyframes info-eyes {
0% {transform:scale(1, 1) }
96% {transform:scale(1, 1) }
98% {transform:scale(1, 0.2) }
100% {transform:scale(1, 1) }
}
#keyframes info-iris {
0% {transform: translate(0%, 0%); opacity: 100%;; }
25% {transform: translate(0%, 8%); opacity: 100%;}
50% {transform: translate(8%, 8%); opacity: 100%;}
75% {transform: translate(8%, 8%); opacity: 100%;}
96% {transform: translate(0%, 0%); opacity: 100%;}
98% {transform: translate(0%, 0%); opacity: 0%;}
100% {transform: translate(0%, 0%); opacity: 100%;}
}
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" width="81.7" height="75.3" viewBox="0 0 81.7 75.3">
<defs>
<style>
.a {
fill: none;
}
.b {
clip-path: url(#a);
}
.h {
fill: #fff;
}
</style>
<clipPath id="a">
<rect class="a" width="81.7" height="75.3" />
</clipPath>
</defs>
<g transform="translate(40.85 37.65)">
<g class="b" transform="translate(-40.85 -37.65)">
<path class="info-eyes" d="M34.8,52.7a7,7,0,1,1-7-7,7,7,0,0,1,7,7" />
<path class="info-eyes" d="M60.7,52.7a7,7,0,1,1-7-7,7,7,0,0,1,7,7" />
<path class="h info-iris" d="M25.9,50.6c0-2-2.5-2.4-2.5,0s2.5,2,2.5,0" />
<path class="h info-iris" d="M51.6,50.6c0-2-2.5-2.4-2.5,0s2.5,2,2.5,0" />
</g>
</g>
</svg>
</body>
I'm using this as a pre-loader and it's working pretty good, but I'd like the "goo" effect to only happen when the moving shapes are actually in contact with the circle in the middle. See how the edges are all blurred up at all times now.
I like that the moving shapes blurs up right when they're in contact with the circle, but when they're at max away from it they should be 100% normal. The way the shape should look like when not in contact with the middle circle:
You can try to comment off the url("#goo") part to see the normal state as well.
.page-preloader-cover {
position: fixed;
z-index: 1200;
top: 0;
left: 0;
display: block;
width: 100%;
height: 100%;
background-color: #fff;
}
.cssload-dots {
width: 200px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
margin: auto;
filter: url("#goo");
-o-filter: url("#goo");
-ms-filter: url("#goo");
-webkit-filter: url("#goo");
-moz-filter: url("#goo");
}
.svg-filter {
position: absolute;
}
.cssload-dot {
width: 0;
height: 0;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%);
-ms-transform: translate(-50%);
transform: translate(-50%);
}
.cssload-dot:before {
content: "";
width: 48px;
height: 48px;
border-radius: 69px;
background: #9664B4;
position: absolute;
left: 50%;
transform: translateY(0);
-o-transform: translateY(0);
-ms-transform: translateY(0);
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
margin-left: -24.5px;
margin-top: -24.5px;
}
.cssload-dot:nth-child(5):before {
z-index: 100;
width: 62.5px;
height: 62.5px;
margin-left: -31.75px;
margin-top: -31.75px;
animation: cssload-dot-colors 4.6s ease infinite;
-o-animation: cssload-dot-colors 4.6s ease infinite;
-ms-animation: cssload-dot-colors 4.6s ease infinite;
-webkit-animation: cssload-dot-colors 4.6s ease infinite;
-moz-animation: cssload-dot-colors 4.6s ease infinite;
}
.cssload-dot:nth-child(1) {
animation: cssload-dot-rotate-1 4.6s 0s linear infinite;
-o-animation: cssload-dot-rotate-1 4.6s 0s linear infinite;
-ms-animation: cssload-dot-rotate-1 4.6s 0s linear infinite;
-webkit-animation: cssload-dot-rotate-1 4.6s 0s linear infinite;
-moz-animation: cssload-dot-rotate-1 4.6s 0s linear infinite;
}
.cssload-dot:nth-child(1):before {
background-color: transparent;
animation: cssload-dot-move 4.6s 0s ease infinite;
-o-animation: cssload-dot-move 4.6s 0s ease infinite;
-ms-animation: cssload-dot-move 4.6s 0s ease infinite;
-webkit-animation: cssload-dot-move 4.6s 0s ease infinite;
-moz-animation: cssload-dot-move 4.6s 0s ease infinite;
background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg"><path style="fill:%2355AF32;" d="M 120 0 L 120 100 A 50 50 0 1 1 20 100 Z"></path></svg>') !important;
}
.cssload-dot:nth-child(2) {
animation: cssload-dot-rotate-2 4.6s 1.15s linear infinite;
-o-animation: cssload-dot-rotate-2 4.6s 1.15s linear infinite;
-ms-animation: cssload-dot-rotate-2 4.6s 1.15s linear infinite;
-webkit-animation: cssload-dot-rotate-2 4.6s 1.15s linear infinite;
-moz-animation: cssload-dot-rotate-2 4.6s 1.15s linear infinite;
}
.cssload-dot:nth-child(2):before {
background-color: transparent;
animation: cssload-dot-move 4.6s 1.15s ease infinite;
-o-animation: cssload-dot-move 4.6s 1.15s ease infinite;
-ms-animation: cssload-dot-move 4.6s 1.15s ease infinite;
-webkit-animation: cssload-dot-move 4.6s 1.15s ease infinite;
-moz-animation: cssload-dot-move 4.6s 1.15s ease infinite;
background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg"><path style="fill:%23ff4a49;" d="M 120 0 L 120 100 A 50 50 0 1 1 20 100 Z"></path></svg>') !important;
}
.cssload-dot:nth-child(3) {
animation: cssload-dot-rotate-3 4.6s 2.3s linear infinite;
-o-animation: cssload-dot-rotate-3 4.6s 2.3s linear infinite;
-ms-animation: cssload-dot-rotate-3 4.6s 2.3s linear infinite;
-webkit-animation: cssload-dot-rotate-3 4.6s 2.3s linear infinite;
-moz-animation: cssload-dot-rotate-3 4.6s 2.3s linear infinite;
}
.cssload-dot:nth-child(3):before {
background-color: transparent;
animation: cssload-dot-move 4.6s 2.3s ease infinite;
-o-animation: cssload-dot-move 4.6s 2.3s ease infinite;
-ms-animation: cssload-dot-move 4.6s 2.3s ease infinite;
-webkit-animation: cssload-dot-move 4.6s 2.3s ease infinite;
-moz-animation: cssload-dot-move 4.6s 2.3s ease infinite;
background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg"><path style="fill:%230A4B9B;" d="M 120 0 L 120 100 A 50 50 0 1 1 20 100 Z"></path></svg>') !important;
}
.cssload-dot:nth-child(4) {
animation: cssload-dot-rotate-4 4.6s 3.45s linear infinite;
-o-animation: cssload-dot-rotate-4 4.6s 3.45s linear infinite;
-ms-animation: cssload-dot-rotate-4 4.6s 3.45s linear infinite;
-webkit-animation: cssload-dot-rotate-4 4.6s 3.45s linear infinite;
-moz-animation: cssload-dot-rotate-4 4.6s 3.45s linear infinite;
}
.cssload-dot:nth-child(4):before {
background-color: transparent;
animation: cssload-dot-move 4.6s 3.45s ease infinite;
-o-animation: cssload-dot-move 4.6s 3.45s ease infinite;
-ms-animation: cssload-dot-move 4.6s 3.45s ease infinite;
-webkit-animation: cssload-dot-move 4.6s 3.45s ease infinite;
-moz-animation: cssload-dot-move 4.6s 3.45s ease infinite;
background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg"><path style="fill:%239664B4;" d="M 120 0 L 120 100 A 50 50 0 1 1 20 100 Z"></path></svg>') !important;
}
#keyframes cssload-dot-move {
0% {
transform: translateY(0);
}
18%, 22% {
transform: translateY(-96px);
}
40%, 100% {
transform: translateY(0);
}
}
#-o-keyframes cssload-dot-move {
0% {
-o-transform: translateY(0);
}
18%, 22% {
-o-transform: translateY(-96px);
}
40%, 100% {
-o-transform: translateY(0);
}
}
#-ms-keyframes cssload-dot-move {
0% {
-ms-transform: translateY(0);
}
18%, 22% {
-ms-transform: translateY(-96px);
}
40%, 100% {
-ms-transform: translateY(0);
}
}
#-webkit-keyframes cssload-dot-move {
0% {
-webkit-transform: translateY(0);
}
18%, 22% {
-webkit-transform: translateY(-96px);
}
40%, 100% {
-webkit-transform: translateY(0);
}
}
#-moz-keyframes cssload-dot-move {
0% {
-moz-transform: translateY(0);
}
18%, 22% {
-moz-transform: translateY(-96px);
}
40%, 100% {
-moz-transform: translateY(0);
}
}
#keyframes cssload-dot-colors {
0% {
background-color: #9664B4; /*#7a6cea*/
}
25% {
background-color: #55AF32; /*#2be1df*/
}
50% {
background-color: #E61423; /*#ff4a4a*/
}
75% {
background-color: #0A4B9B; /*#3b55e6*/
}
100% {
background-color: #9664B4;
}
}
#-o-keyframes cssload-dot-colors {
0% {
background-color: #9664B4;
}
25% {
background-color: #55AF32;
}
50% {
background-color: #ff4a49;
}
75% {
background-color: #0A4B9B;
}
100% {
background-color: #9664B4;
}
}
#-ms-keyframes cssload-dot-colors {
0% {
background-color: #9664B4;
}
25% {
background-color: #55AF32;
}
50% {
background-color: #ff4a49;
}
75% {
background-color: #0A4B9B;
}
100% {
background-color: #9664B4;
}
}
#-webkit-keyframes cssload-dot-colors {
0% {
background-color: #9664B4;
}
25% {
background-color: #55AF32;
}
50% {
background-color: #ff4a49;
}
75% {
background-color: #0A4B9B;
}
100% {
background-color: #9664B4;
}
}
#-moz-keyframes cssload-dot-colors {
0% {
background-color: #9664B4;
}
25% {
background-color: #55AF32;
}
50% {
background-color: #ff4a49;
}
75% {
background-color: #0A4B9B;
}
100% {
background-color: #9664B4;
}
}
#keyframes cssload-dot-rotate-1 {
0% {
transform: rotate(-105deg);
}
100% {
transform: rotate(270deg);
}
}
#-o-keyframes cssload-dot-rotate-1 {
0% {
-o-transform: rotate(-105deg);
}
100% {
-o-transform: rotate(270deg);
}
}
#-ms-keyframes cssload-dot-rotate-1 {
0% {
-ms-transform: rotate(-105deg);
}
100% {
-ms-transform: rotate(270deg);
}
}
#-webkit-keyframes cssload-dot-rotate-1 {
0% {
-webkit-transform: rotate(-105deg);
}
100% {
-webkit-transform: rotate(270deg);
}
}
#-moz-keyframes cssload-dot-rotate-1 {
0% {
-moz-transform: rotate(-105deg);
}
100% {
-moz-transform: rotate(270deg);
}
}
#keyframes cssload-dot-rotate-2 {
0% {
transform: rotate(165deg);
}
100% {
transform: rotate(540deg);
}
}
#-o-keyframes cssload-dot-rotate-2 {
0% {
-o-transform: rotate(165deg);
}
100% {
-o-transform: rotate(540deg);
}
}
#-ms-keyframes cssload-dot-rotate-2 {
0% {
-ms-transform: rotate(165deg);
}
100% {
-ms-transform: rotate(540deg);
}
}
#-webkit-keyframes cssload-dot-rotate-2 {
0% {
-webkit-transform: rotate(165deg);
}
100% {
-webkit-transform: rotate(540deg);
}
}
#-moz-keyframes cssload-dot-rotate-2 {
0% {
-moz-transform: rotate(165deg);
}
100% {
-moz-transform: rotate(540deg);
}
}
#keyframes cssload-dot-rotate-3 {
0% {
transform: rotate(435deg);
}
100% {
transform: rotate(810deg);
}
}
#-o-keyframes cssload-dot-rotate-3 {
0% {
-o-transform: rotate(435deg);
}
100% {
-o-transform: rotate(810deg);
}
}
#-ms-keyframes cssload-dot-rotate-3 {
0% {
-ms-transform: rotate(435deg);
}
100% {
-ms-transform: rotate(810deg);
}
}
#-webkit-keyframes cssload-dot-rotate-3 {
0% {
-webkit-transform: rotate(435deg);
}
100% {
-webkit-transform: rotate(810deg);
}
}
#-moz-keyframes cssload-dot-rotate-3 {
0% {
-moz-transform: rotate(435deg);
}
100% {
-moz-transform: rotate(810deg);
}
}
#keyframes cssload-dot-rotate-4 {
0% {
transform: rotate(705deg);
}
100% {
transform: rotate(1080deg);
}
}
#-o-keyframes cssload-dot-rotate-4 {
0% {
-o-transform: rotate(705deg);
}
100% {
-o-transform: rotate(1080deg);
}
}
#-ms-keyframes cssload-dot-rotate-4 {
0% {
-ms-transform: rotate(705deg);
}
100% {
-ms-transform: rotate(1080deg);
}
}
#-webkit-keyframes cssload-dot-rotate-4 {
0% {
-webkit-transform: rotate(705deg);
}
100% {
-webkit-transform: rotate(1080deg);
}
}
#-moz-keyframes cssload-dot-rotate-4 {
0% {
-moz-transform: rotate(705deg);
}
100% {
-moz-transform: rotate(1080deg);
}
}
<div class="page-preloader-cover">
<div class="cssload-dots">
<div class="cssload-dot"></div>
<div class="cssload-dot"></div>
<div class="cssload-dot"></div>
<div class="cssload-dot"></div>
<div class="cssload-dot"></div>
</div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" class="svg-filter">
<defs>
<filter id="goo">
<feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="12"></feGaussianBlur>
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" ></feColorMatrix>
</filter>
</defs>
</svg>
</div>
Here's your loader converted to SVG format.
The relevant part related to the blob blur is here:
<feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="12">
<animate attributeName="stdDeviation"
keyTimes="0; 0.5; 0.9; 1.0"
values="12; 0; 0; 12"
dur="1.15s" repeatCount="indefinite"/>
</feGaussianBlur>
What's happening is that the blur reduces to 0 and back to 12 again every 1.15s to coincide with the movement of the shapes. Over that 1.15sec interval, stdDeviation goes:
from 12 at (0 * 1.15s) to 0 at (0.5 * 1.15s), then
from 0 at (0.9 * 1.15s) to 12 at (1 * 1.15s)
IOW, the keyTimes values represent percentages of that 1.15s animation duration. If you wish, you can tweak those keyTimes values to adjust the timing of the blur animation.
.page-preloader-cover {
position: fixed;
z-index: 1200;
top: 0;
left: 0;
display: block;
width: 100%;
height: 100%;
background-color: #fff;
}
.page-preloader-cover svg {
width: 200px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
overflow: visible;
}
<div class="page-preloader-cover">
<svg viewBox="0 0 200 200">
<defs>
<filter id="goo">
<feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="12">
<animate attributeName="stdDeviation"
keyTimes="0; 0.5; 0.9; 1.0"
values="12; 2; 2; 12"
dur="1.15s" repeatCount="indefinite"/>
</feGaussianBlur>
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" ></feColorMatrix>
</filter>
<symbol id="shape" viewBox="0 0 150 150">
<path d="M 120 0 L 120 100 A 50 50 0 1 1 20 100 Z"/>
</symbol>
</defs>
<g transform="translate(100,100)" filter="url(#goo)">
<animate attributeName="filter"
keyTimes="0; 0.4; 0.9; 1.0"
values="url(#goo); none; none; url(#goo)"
dur="1.15s" repeatCount="indefinite"/>
<g>
<use x="-24" y="-24" width="48" height="48" xlink:href="#shape" fill="#55AF32">
<animate attributeName="y" dur="4.6s" repeatCount="indefinite"
calcMode="spline"
keySplines="0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0"
keyTimes="0; 0.18; 0.22; 0.4; 1.0"
values="-24; -120; -120; -24; -24"/>
</use>
<animateTransform attributeName="transform"
type="rotate" from="-105" to="270"
dur="4.6s" repeatCount="indefinite"/>
</g>
<g>
<use x="-24" y="-24" width="48" height="48" xlink:href="#shape" fill="#ff4a49">
<animate attributeName="y" dur="4.6s" repeatCount="indefinite" begin="1.15s"
calcMode="spline"
keySplines="0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0"
keyTimes="0; 0.18; 0.22; 0.4; 1.0"
values="-24; -120; -120; -24; -24"/>
</use>
<animateTransform attributeName="transform"
type="rotate" from="165" to="540"
dur="4.6s" repeatCount="indefinite" begin="1.15s"/>
</g>
<g>
<use x="-24" y="-24" width="48" height="48" xlink:href="#shape" fill="#0A4B9B">
<animate attributeName="y" dur="4.6s" repeatCount="indefinite" begin="2.3s"
calcMode="spline"
keySplines="0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0"
keyTimes="0; 0.18; 0.22; 0.4; 1.0"
values="-24; -120; -120; -24; -24"/>
</use>
<animateTransform attributeName="transform"
type="rotate" from="435" to="810"
dur="4.6s" repeatCount="indefinite" begin="2.35s"/>
</g>
<g>
<use x="-24" y="-24" width="48" height="48" xlink:href="#shape" fill="#9664B4">
<animate attributeName="y" dur="4.6s" repeatCount="indefinite" begin="3.45s"
calcMode="spline"
keySplines="0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0; 0.25 0.1 0.25 1.0"
keyTimes="0; 0.18; 0.22; 0.4; 1.0"
values="-24; -120; -120; -24; -24"/>
</use>
<animateTransform attributeName="transform"
type="rotate" from="705" to="1080"
dur="4.6s" repeatCount="indefinite" begin="3.45s"/>
</g>
<circle cx="0" cy="0" r="31.25" fill="#9664B4">
<animate attributeName="fill" dur="4.6s" repeatCount="indefinite"
keyTimes="0; 0.25; 0.5; 0.75; 1"
values="#9664B4; #55AF32; #E61423; #0A4B9B; #9664B4"/>
</circle>
</g>
</svg>
</div>
I want to change the size of Rocket in below source code:
https://jsfiddle.net/umaar/4FMyA/
I have been trying many ways, but still has no effect.
Actually, I want to make the Rocket a bit smaller.
Thanks
/*=============================================
[ Page Setup ]
==============================================*/
body {
background: #34495e
}
#pageWrap {
width: 100%;
overflow: hidden;
}
#rocket {
display: block;
margin: 0 auto;
margin-top: 150px;
}
/*=============================================
[ Inactive State Styles ]
==============================================*/
.rocket_inner {
transform: translateY(15px) translateX(-3px);
-webkit-transition: .3s;
-moz-transition: .3s;
transition: .3s;
}
.icon_circle {
transition: .2s;
fill: #22303e;
}
.large_window_path {
transition: .2s;
fill: #22303e;
}
.small_window_path {
fill: #22303e;
}
.wing_shadow {
fill: #34495e;
}
.rocket_bottom {
fill: #34495e
}
.rocket_base {
fill: #34495e
}
.rocket_shadow {
fill: #34495e
}
.window_grandient {
stop-color: #2DCB73
}
.window_grandient1 {
stop-color: #2AC16D
}
.window_grandient2 {
stop-color: #29B968
}
.window_grandient3 {
stop-color: #28B767
}
.wing_base {
fill: #34495e
}
.fire_path {
fill: #FC0
}
/*=============================================
[ Hover Styles ]
==============================================*/
.rocket_wrap:hover .rocket_base {
fill: #FFFFFF !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_shadow {
fill: #EDEDED !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .icon_circle {
fill: #282e3a !important;
stroke: #fff !important;
stroke-width: 7px !important;
}
.rocket_wrap:hover .small_window_path {
fill: #28B767 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .wing_shadow {
display: block !important;
fill: #FC9252 !important;
}
.rocket_wrap:hover .wing_base {
fill: #E16E36 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_bottom {
fill: #2DCB73 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .large_window_path {
fill: url(#SVGID_2_) !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_inner {
transform: translateY(0px) translateX(-3px) !important;
}
/*=============================================
[ Animation Classes ]
==============================================*/
.fire {
display: none;
animation-delay: 0s;
fill-opacity: 1;
animation-timing-function: ease-in;
stroke-width: 0px;
animation-iteration-count: infinite;
animation-timing-function: linear;
transform-origin: 50% 50%;
animation-direction: normal;
}
.rocket_wrap:hover #fireLeft {
display: block;
animation-delay: 0s;
animation-name: fireLeft, fillOpacity1;
animation-duration: 1.2s;
}
.rocket_wrap:hover #fireMiddle {
display: block;
animation-delay: 0s;
animation-name: fireMiddle, fillOpacity1;
animation-duration: 1s;
}
.rocket_wrap:hover #fireRight {
display: block;
animation-delay: 0s;
animation-name: fireRight, fillOpacity1;
animation-duration: 1.3s;
}
.rocket_wrap:hover #fireSmallLeft {
display: block;
animation-delay: 0s;
animation-name: fireSmall, fillOpacity2;
animation-duration: 1.3s;
transform-origin: bottom;
}
.rocket_wrap:hover #fireSmallRight {
display: block;
animation-delay: 0.3s;
animation-name: fireSmall, fillOpacity3;
animation-duration: 1.6s;
transform-origin: bottom;
}
/*=============================================
[ KeyFrame Animations ]
==============================================*/
#keyframes fireSmall {
10% {
transform: rotate(17deg) translateY(1px)
}
20% {
transform: rotate(-13deg) translateY(2px)
}
30% {
transform: rotate(21deg) translateY(3px)
}
40% {
transform: rotate(-34deg)translateY(4px)
}
50% {
transform: rotate(24deg) translateY(5px)
}
60% {
transform: rotate(-17deg) translateY(6px)
}
70% {
transform: rotate(31deg) translateY(7px)
}
80% {
transform: rotate(-28deg) translateY(8px)
}
90% {
transform: rotate(14deg) translateY(9px)
}
99% {
transform: rotate(0deg) translateY(10px)
}
}
#keyframes fireLeft {
6% {
transform: rotate(25deg)
}
15% {
transform: rotate(-19deg)
}
25% {
transform: rotate(25deg)
}
32% {
transform: rotate(-30deg)
}
46% {
transform: rotate(22deg)
}
54% {
transform: rotate(-29deg)
}
61% {
transform: rotate(32deg)
}
74% {
transform: rotate(-9deg)
}
83% {
transform: rotate(16deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fireMiddle {
10% {
transform: rotate(25deg)
}
20% {
transform: rotate(-25deg)
}
30% {
transform: rotate(30deg)
}
40% {
transform: rotate(-22deg)
}
50% {
transform: rotate(29deg)
}
60% {
transform: rotate(-45deg)
}
70% {
transform: rotate(37deg)
}
80% {
transform: rotate(-15deg)
}
90% {
transform: rotate(16deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fireRight {
15% {
transform: rotate(17deg)
}
23% {
transform: rotate(-13deg)
}
37% {
transform: rotate(21deg)
}
45% {
transform: rotate(-34deg)
}
54% {
transform: rotate(24deg)
}
67% {
transform: rotate(-17deg)
}
72% {
transform: rotate(31deg)
}
84% {
transform: rotate(-28deg)
}
96% {
transform: rotate(14deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fillOpacity1 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
50% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes fillOpacity2 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
25% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes fillOpacity3 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
67% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes rocektMove {
0% {
transform: translateY(0px)
}
100% {
transform: translateY(20px)
}
}
<!-- http://www.pencilscoop.com/2013/11/animate-svg-icons-with-css3-jquery/ -->
<div id="pageWrap">
<svg version="1.1" x="0px" y="0px" width="307px" height="283px" id="rocket">
<g class="rocket_wrap">
<circle cx="147.5" cy="138.6" r="105.5" class="icon_circle"/>
<g class="rocket_inner">
<path class="fire fire_path" id="fireMiddle" d="M148.891,179.906c3.928,0,7.111,3.176,7.111,7.094 c0,7.78-7.111,16-7.111,16s-7.111-8.349-7.111-16C141.78,183.082,144.963,179.906,148.891,179.906z"/>
<path class="fire_path fire" id="fireRight" d="M154.063,181.092c3.577-1.624,7.788-0.048,9.408,3.52 c3.216,7.084,0.139,17.508,0.139,17.508s-9.927-4.662-13.09-11.63C148.9,186.923,150.487,182.715,154.063,181.092z"/>
<path class="fire_path fire" id="fireLeft" d="M143.392,182.519c3.25,2.207,4.098,6.623,1.896,9.864 c-4.372,6.436-14.873,9.238-14.873,9.238s-1.191-10.902,3.108-17.23C135.725,181.149,140.143,180.312,143.392,182.519z"/>
<path class="fire_path fire" id="fireSmallLeft" d="M143.193 187.531c2.226 0.4 3.7 2.6 3.2 4.8 c-0.875 4.407-5.829 8.264-5.829 8.264s-3.09-5.53-2.229-9.865C138.807 188.5 141 187.1 143.2 187.531z"/>
<path class="fire_path fire" id="fireSmallRight" d="M152.089 188.599c2.043-0.985 4.496-0.132 5.5 1.9 c1.952 4 0.3 10.1 0.3 10.107s-5.795-2.56-7.713-6.541C149.186 192 150 189.6 152.1 188.599z"/>
<path class="rocket_bottom" d="M157.069 171.31h-3.292c-1.562-0.048-3.178-0.076-4.846-0.076 s-3.284 0.028-4.846 0.076h-3.292c-7.277-7.938-12.371-26.182-12.371-47.434c0-28.54 9.182-51.676 20.508-51.676 c11.327 0 20.5 23.1 20.5 51.676C169.44 145.1 164.3 163.4 157.1 171.31z"/>
<g id="right_wing_wrap">
<path class="wing_base" d="M166.678 127.161c0 0 17.7 3.3 12.9 48.099l-18.06-14.05 L166.678 127.161z"/>
<path class="wing_shadow" d="M158.225 140.336c10.481-5.584 22.7 22.2 21.4 34.9 l-18.06-14.05C161.542 161.2 156.1 144.3 158.2 140.336z"/>
</g>
<g id="left_wing_wrap">
<path class="wing_base" d="M135.131 161.21l-18.06 14.1 c-4.805-44.793 12.924-48.099 12.924-48.099L135.131 161.21z"/>
<path class="wing_shadow" d="M135.131 161.21l-18.06 14.1 c-1.367-12.746 10.896-40.509 21.377-34.924C140.614 144.3 135.1 161.2 135.1 161.21z"/>
</g>
<g id="rocket_body_wrap">
<path class="rocket_base" d="M162.728 167.358c-3.778-0.623-8.573-0.996-13.796-0.996 s-10.018 0.373-13.795 0.996c-5.033-10.186-8.257-25.808-8.257-43.338c0-30.688 9.873-55.566 22.052-55.566 s22.053 24.9 22.1 55.566C170.984 141.6 167.8 157.2 162.7 167.358z" />
<path class="rocket_shadow" d="M145.464 166.417c19.578-40.575 7.26-85.229 4.112-98.067 c11.88 0.9 21.4 25.4 21.4 55.525c0 17.529-3.225 33.152-8.257 43.337c0 0-3.786-0.472-8.069-0.697 S145.464 166.4 145.5 166.417z"/>
</g>
<g id="large_window_wrap">
<radialgradient id="SVGID_2_" cx="148.9" cy="112.5" r="15.2" fx="139.4853" fy="112.5239" gradientunits="userSpaceOnUse">
<stop offset="0" class="window_grandient"/>
<stop offset="0.5868" class="window_grandient"/>
<stop offset="0.6834" class="window_grandient"/>
<stop offset="0.6845" class="window_grandient1"/>
<stop offset="0.6861" class="window_grandient2"/>
<stop offset="0.6897" class="window_grandient3"/>
</radialgradient>
<circle class="large_window_path" cx="148.9" cy="111.3" r="10.5"/>
</g>
<circle class="small_window_path" cx="148.9" cy="132.4" r="5.2"/>
</g>
</g>
</svg>
</div>
for any suggestion.
You may simply use scale on the most upper g and adjust position by adding a translation if needed:
/*=============================================
[ Page Setup ]
==============================================*/
body {
background: #34495e
}
#pageWrap {
width: 100%;
overflow: hidden;
}
#rocket {
display: block;
margin: 0 auto;
margin-top: 150px;
}
/*=============================================
[ Inactive State Styles ]
==============================================*/
.rocket_inner {
transform: translateY(15px) translateX(-3px);
-webkit-transition: .3s;
-moz-transition: .3s;
transition: .3s;
}
.icon_circle {
transition: .2s;
fill: #22303e;
}
.large_window_path {
transition: .2s;
fill: #22303e;
}
.small_window_path {
fill: #22303e;
}
.wing_shadow {
fill: #34495e;
}
.rocket_bottom {
fill: #34495e
}
.rocket_base {
fill: #34495e
}
.rocket_shadow {
fill: #34495e
}
.window_grandient {
stop-color: #2DCB73
}
.window_grandient1 {
stop-color: #2AC16D
}
.window_grandient2 {
stop-color: #29B968
}
.window_grandient3 {
stop-color: #28B767
}
.wing_base {
fill: #34495e
}
.fire_path {
fill: #FC0
}
/*=============================================
[ Hover Styles ]
==============================================*/
.rocket_wrap:hover .rocket_base {
fill: #FFFFFF !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_shadow {
fill: #EDEDED !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .icon_circle {
fill: #282e3a !important;
stroke: #fff !important;
stroke-width: 7px !important;
}
.rocket_wrap:hover .small_window_path {
fill: #28B767 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .wing_shadow {
display: block !important;
fill: #FC9252 !important;
}
.rocket_wrap:hover .wing_base {
fill: #E16E36 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_bottom {
fill: #2DCB73 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .large_window_path {
fill: url(#SVGID_2_) !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_inner {
transform: translateY(0px) translateX(-3px) !important;
}
/*=============================================
[ Animation Classes ]
==============================================*/
.fire {
display: none;
animation-delay: 0s;
fill-opacity: 1;
animation-timing-function: ease-in;
stroke-width: 0px;
animation-iteration-count: infinite;
animation-timing-function: linear;
transform-origin: 50% 50%;
animation-direction: normal;
}
.rocket_wrap:hover #fireLeft {
display: block;
animation-delay: 0s;
animation-name: fireLeft, fillOpacity1;
animation-duration: 1.2s;
}
.rocket_wrap:hover #fireMiddle {
display: block;
animation-delay: 0s;
animation-name: fireMiddle, fillOpacity1;
animation-duration: 1s;
}
.rocket_wrap:hover #fireRight {
display: block;
animation-delay: 0s;
animation-name: fireRight, fillOpacity1;
animation-duration: 1.3s;
}
.rocket_wrap:hover #fireSmallLeft {
display: block;
animation-delay: 0s;
animation-name: fireSmall, fillOpacity2;
animation-duration: 1.3s;
transform-origin: bottom;
}
.rocket_wrap:hover #fireSmallRight {
display: block;
animation-delay: 0.3s;
animation-name: fireSmall, fillOpacity3;
animation-duration: 1.6s;
transform-origin: bottom;
}
/*=============================================
[ KeyFrame Animations ]
==============================================*/
#keyframes fireSmall {
10% {
transform: rotate(17deg) translateY(1px)
}
20% {
transform: rotate(-13deg) translateY(2px)
}
30% {
transform: rotate(21deg) translateY(3px)
}
40% {
transform: rotate(-34deg)translateY(4px)
}
50% {
transform: rotate(24deg) translateY(5px)
}
60% {
transform: rotate(-17deg) translateY(6px)
}
70% {
transform: rotate(31deg) translateY(7px)
}
80% {
transform: rotate(-28deg) translateY(8px)
}
90% {
transform: rotate(14deg) translateY(9px)
}
99% {
transform: rotate(0deg) translateY(10px)
}
}
#keyframes fireLeft {
6% {
transform: rotate(25deg)
}
15% {
transform: rotate(-19deg)
}
25% {
transform: rotate(25deg)
}
32% {
transform: rotate(-30deg)
}
46% {
transform: rotate(22deg)
}
54% {
transform: rotate(-29deg)
}
61% {
transform: rotate(32deg)
}
74% {
transform: rotate(-9deg)
}
83% {
transform: rotate(16deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fireMiddle {
10% {
transform: rotate(25deg)
}
20% {
transform: rotate(-25deg)
}
30% {
transform: rotate(30deg)
}
40% {
transform: rotate(-22deg)
}
50% {
transform: rotate(29deg)
}
60% {
transform: rotate(-45deg)
}
70% {
transform: rotate(37deg)
}
80% {
transform: rotate(-15deg)
}
90% {
transform: rotate(16deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fireRight {
15% {
transform: rotate(17deg)
}
23% {
transform: rotate(-13deg)
}
37% {
transform: rotate(21deg)
}
45% {
transform: rotate(-34deg)
}
54% {
transform: rotate(24deg)
}
67% {
transform: rotate(-17deg)
}
72% {
transform: rotate(31deg)
}
84% {
transform: rotate(-28deg)
}
96% {
transform: rotate(14deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fillOpacity1 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
50% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes fillOpacity2 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
25% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes fillOpacity3 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
67% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes rocektMove {
0% {
transform: translateY(0px)
}
100% {
transform: translateY(20px)
}
}
<!-- http://www.pencilscoop.com/2013/11/animate-svg-icons-with-css3-jquery/ -->
<div id="pageWrap">
<svg version="1.1" x="0px" y="0px" width="307px" height="283px" id="rocket">
<g class="rocket_wrap" transform="scale(0.5)">
<circle cx="147.5" cy="138.6" r="105.5" class="icon_circle"/>
<g class="rocket_inner">
<path class="fire fire_path" id="fireMiddle" d="M148.891,179.906c3.928,0,7.111,3.176,7.111,7.094 c0,7.78-7.111,16-7.111,16s-7.111-8.349-7.111-16C141.78,183.082,144.963,179.906,148.891,179.906z"/>
<path class="fire_path fire" id="fireRight" d="M154.063,181.092c3.577-1.624,7.788-0.048,9.408,3.52 c3.216,7.084,0.139,17.508,0.139,17.508s-9.927-4.662-13.09-11.63C148.9,186.923,150.487,182.715,154.063,181.092z"/>
<path class="fire_path fire" id="fireLeft" d="M143.392,182.519c3.25,2.207,4.098,6.623,1.896,9.864 c-4.372,6.436-14.873,9.238-14.873,9.238s-1.191-10.902,3.108-17.23C135.725,181.149,140.143,180.312,143.392,182.519z"/>
<path class="fire_path fire" id="fireSmallLeft" d="M143.193 187.531c2.226 0.4 3.7 2.6 3.2 4.8 c-0.875 4.407-5.829 8.264-5.829 8.264s-3.09-5.53-2.229-9.865C138.807 188.5 141 187.1 143.2 187.531z"/>
<path class="fire_path fire" id="fireSmallRight" d="M152.089 188.599c2.043-0.985 4.496-0.132 5.5 1.9 c1.952 4 0.3 10.1 0.3 10.107s-5.795-2.56-7.713-6.541C149.186 192 150 189.6 152.1 188.599z"/>
<path class="rocket_bottom" d="M157.069 171.31h-3.292c-1.562-0.048-3.178-0.076-4.846-0.076 s-3.284 0.028-4.846 0.076h-3.292c-7.277-7.938-12.371-26.182-12.371-47.434c0-28.54 9.182-51.676 20.508-51.676 c11.327 0 20.5 23.1 20.5 51.676C169.44 145.1 164.3 163.4 157.1 171.31z"/>
<g id="right_wing_wrap">
<path class="wing_base" d="M166.678 127.161c0 0 17.7 3.3 12.9 48.099l-18.06-14.05 L166.678 127.161z"/>
<path class="wing_shadow" d="M158.225 140.336c10.481-5.584 22.7 22.2 21.4 34.9 l-18.06-14.05C161.542 161.2 156.1 144.3 158.2 140.336z"/>
</g>
<g id="left_wing_wrap">
<path class="wing_base" d="M135.131 161.21l-18.06 14.1 c-4.805-44.793 12.924-48.099 12.924-48.099L135.131 161.21z"/>
<path class="wing_shadow" d="M135.131 161.21l-18.06 14.1 c-1.367-12.746 10.896-40.509 21.377-34.924C140.614 144.3 135.1 161.2 135.1 161.21z"/>
</g>
<g id="rocket_body_wrap">
<path class="rocket_base" d="M162.728 167.358c-3.778-0.623-8.573-0.996-13.796-0.996 s-10.018 0.373-13.795 0.996c-5.033-10.186-8.257-25.808-8.257-43.338c0-30.688 9.873-55.566 22.052-55.566 s22.053 24.9 22.1 55.566C170.984 141.6 167.8 157.2 162.7 167.358z" />
<path class="rocket_shadow" d="M145.464 166.417c19.578-40.575 7.26-85.229 4.112-98.067 c11.88 0.9 21.4 25.4 21.4 55.525c0 17.529-3.225 33.152-8.257 43.337c0 0-3.786-0.472-8.069-0.697 S145.464 166.4 145.5 166.417z"/>
</g>
<g id="large_window_wrap">
<radialgradient id="SVGID_2_" cx="148.9" cy="112.5" r="15.2" fx="139.4853" fy="112.5239" gradientunits="userSpaceOnUse">
<stop offset="0" class="window_grandient"/>
<stop offset="0.5868" class="window_grandient"/>
<stop offset="0.6834" class="window_grandient"/>
<stop offset="0.6845" class="window_grandient1"/>
<stop offset="0.6861" class="window_grandient2"/>
<stop offset="0.6897" class="window_grandient3"/>
</radialgradient>
<circle class="large_window_path" cx="148.9" cy="111.3" r="10.5"/>
</g>
<circle class="small_window_path" cx="148.9" cy="132.4" r="5.2"/>
</g>
</g>
</svg>
</div>
You cannot add style to an SVG <g> element. Its only purpose is to group children. That means, too, that style attributes you give to it are given down to its children, so a fill="green" on the <g> means an automatic fill="green" on its child <rect> (as long as it has no own fill specification).
Your only option is to add a new <rect> to the SVG and place it accordingly to match the <g> children's dimensions.
As you will see from the code below I have a lovely circular progress bar however I have a few questions and a little lost on how to achieve this (ideally I don't want to use any JS)
I want to make the pink bar that goes around be curved and not
flat, is this possible? like the edge of it. So instead of it being
| it would be a little like ) at the start and end.
The throbbing circle in the middle, is it possible for it to pause
for like 1 second once animation is complete before it starts
again?
/* Load Progress Animation */
#-webkit-keyframes load {
0% {
stroke-dashoffset: 0
}
}
#-moz-keyframes load {
0% {
stroke-dashoffset: 0
}
}
#keyframes load {
0% {
stroke-dashoffset: 0
}
}
/* Qik Progress Container */
.progress {
position: relative;
display: inline-block;
padding: 0;
text-align: center;
}
/* Item SVG */
.progress svg {
width: 4rem;
height: 4rem;
}
.progress svg:nth-child(2) {
position: absolute;
left: 0;
top: 0;
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
}
.progress svg:nth-child(2) path {
fill: none;
stroke-width: 20;
stroke-dasharray: 629;
stroke: rgba(60, 99, 121, 0.9);
-webkit-animation: load 8s;
-moz-animation: load 8s;
-o-animation: load 8s;
animation: load 8s;
}
.pulse {
border-radius: 50%;
width: 18px;
height: 18px;
background: #ff1251;
position: absolute;
top: 1.45rem;
left: 1.45rem;
-webkit-animation: pulse 0.6s linear infinite;
-moz-animation: pulse 0.6s linear infinite;
-ms-animation: pulse 0.6s linear infinite;
animation: pulse 0.6s linear infinite;
}
#keyframes "pulse" {
0% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
50% {
-moz-transform: scale(0.8);
-o-transform: scale(0.8);
-ms-transform: scale(0.8);
transform: scale(0.8);
}
100% {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
}
#-moz-keyframes pulse {
0% {
-moz-transform: scale(1);
transform: scale(1);
}
50% {
-moz-transform: scale(0.8);
transform: scale(0.8);
}
100% {
-moz-transform: scale(1);
transform: scale(1);
}
}
#-webkit-keyframes "pulse" {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
50% {
-webkit-transform: scale(0.8);
transform: scale(0.8);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
#-ms-keyframes "pulse" {
0% {
-ms-transform: scale(1);
transform: scale(1);
}
50% {
-ms-transform: scale(0.8);
transform: scale(0.8);
}
100% {
-ms-transform: scale(1);
transform: scale(1);
}
}
<div class="progress">
<svg viewBox="-10 -10 220 220">
<g fill="none" stroke-width="20" transform="translate(100,100)">
<path d="M-100,0a100,100 0 1,0 200,0a100,100 0 1,0 -200,0" stroke="#FF1252" stroke-linejoin="round" />
</g>
</svg>
<svg viewBox="-10 -10 220 220">
<path d="M200,100 C200,44.771525 155.228475,0 100,0 C44.771525,0 0,44.771525 0,100 C0,155.228475 44.771525,200 100,200 C155.228475,200 200,155.228475 200,100 Z" stroke-dashoffset="629"></path>
</svg>
<div class="pulse"></div>
</div>
I've re-written the entire code.
For your first question, you could simply use stroke-linecap="round".
For the second one, you will have to add an extra #keyframes rule for the delay.
body {
background: #072237;
}
h3 {
color: #ffffff;
}
#loader {
position: relative;
width: 80px;
height: 80px;
}
#ring {
-webkit-animation: load 6s 1 forwards;
animation: load 6s 1 forwards;
}
#circle {
position: absolute;
width: 20px;
height: 20px;
top: 50%;
left: 50%;
margin-left: -10px;
margin-top: -10px;
background: #FF1251;
border-radius: 50%;
transform: scale(0.8);
-webkit-animation: pulse 1.2s 3;
animation: pulse 1.2s 3;
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
}
#-webkit-keyframes pulse {
0% {
transform: scale(0.8);
}
20% {
transform: scale(1);
}
40% {
transform: scale(0.8);
}
100% {
transform: scale(0.8);
}
}
#keyframes pulse {
0% {
transform: scale(0.8);
}
20% {
transform: scale(1);
}
40% {
transform: scale(0.8);
}
100% {
transform: scale(0.8);
}
}
#-webkit-keyframes load {
80% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes load {
80% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
<div id="loader">
<svg height="80" width="80" viewBox="-10 -10 220 220">
<path id="back" d="M0,100 a100,100 0 1 0 200,0 a100,100 0 1 0 -200,0" fill="#FFFFFF" stroke="#034870" stroke-width="20" stroke-linecap="round" />
<path id="ring" d="M100,0 a100,100 0 0 1 0,200 a100,100 0 0 1 0,-200,0" fill="none" stroke="#FF1251" stroke-width="20" stroke-dasharray="629" stroke-linecap="round" stroke-dashoffset="629" />
</svg>
<div id="circle"></div>
</div>
No. 1. is possible using stroke-linecap, but it requires some changes to your code, becasue in your case the red line is actually a background and the gray the stroke - so it would result in a concave circle, so "(", not ")" at the end of the red line. 2. can be done using longer animation set to alternate so it "sleeps" between 50% and 100% and back. I've made some changes:
http://jsfiddle.net/3yq3kmo1/
Changes in SVG (the second element):
<svg viewBox="-10 -10 220 220">
<circle r="100" cx="100" cy="100" stroke-dashoffset="0" />
</svg>
CSS (note that the dashoffset has been reversed, so now a red stroke grows and hides the gray, instead of red shrinking and revealing the gray; the stroke on path in first SVG element is gray now.)
.progress svg:nth-child(2) circle {
fill: none;
stroke-width: 20;
stroke-dasharray: 629;
stroke: #ff1251;
stroke-linecap:round;
animation: load 8s;
}
The pause in animation:
.pulse {
animation: pulse 1.6s linear infinite alternate;
}
#keyframes pulse {
0% {
transform: scale(0.8);
}
50% {
transform: scale(1);
}
100% {
transform: scale(1);
}
}
I came across this super cool demo of a SVG rocket getting ready to blast off.
http://jsfiddle.net/timrpeterson/4FMyA/22/
first line of the JSFiddle:
<svg version="1.1" x="0px" y="0px" width="307px" height="283px" id="rocket">
I know the point of SVG is to be "scalable" but I just realized I have no idea how this is done. I'd like to shrink the entire rocket and circle surrounding it by 75%, but it looks like everything has defined dimensions.
Is there a simple way to shrink everything the same amount or do I have to manually scale each value?
I would make it like this:
Remove width and height from the svg, add a viewbox with the width/height attributes, add an preserveAspectRatio attribute with "xMinYMin meet" value and then absolute position the svg inside a relative positioned div with width: 100% and max-width that you want the element to be. The last part is the padding-bottom value that serves us as the aspect ratio when we resize the svg element. Long story short this is it.
Change the max-width value of .svg-container to see the svg scale :) Working demo: http://jsfiddle.net/timrpeterson/4FMyA/26/
/*=============================================
[ Page Setup ]
==============================================*/
body {
background: #34495e
}
#pageWrap {
width: 100%;
overflow: hidden;
}
.svg-container {
display: block;
position: relative;
width: 100%;
vertical-align: middle;
overflow: hidden;
max-width: 100px;
margin: 0 auto;
padding-bottom: 64%;
}
#rocket {
display: inline-block;
position: absolute;
top: 0;
left: 0;
}
/*=============================================
[ Inactive State Styles ]
==============================================*/
.rocket_inner {
transform: translateY(15px) translateX(-3px);
-webkit-transition: .3s;
-moz-transition: .3s;
transition: .3s;
}
.icon_circle {
transition: .2s;
fill: #22303e;
}
.large_window_path {
transition: .2s;
fill: #22303e;
}
.small_window_path {
fill: #22303e;
}
.wing_shadow {
fill: #34495e;
}
.rocket_bottom {
fill: #34495e
}
.rocket_base {
fill: #34495e
}
.rocket_shadow {
fill: #34495e
}
.window_grandient {
stop-color: #2DCB73
}
.window_grandient1 {
stop-color: #2AC16D
}
.window_grandient2 {
stop-color: #29B968
}
.window_grandient3 {
stop-color: #28B767
}
.wing_base {
fill: #34495e
}
.fire_path {
fill: #FC0
}
/*=============================================
[ Hover Styles ]
==============================================*/
.rocket_wrap:hover .rocket_base {
fill: #FFFFFF !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_shadow {
fill: #EDEDED !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .icon_circle {
fill: #282e3a !important;
stroke: #fff !important;
stroke-width: 7px !important;
}
.rocket_wrap:hover .small_window_path {
fill: #28B767 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .wing_shadow {
display: block !important;
fill: #FC9252 !important;
}
.rocket_wrap:hover .wing_base {
fill: #E16E36 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_bottom {
fill: #2DCB73 !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .large_window_path {
fill: url(#SVGID_2_) !important;
stroke-width: 0px !important;
}
.rocket_wrap:hover .rocket_inner {
transform: translateY(0px) translateX(-3px) !important;
}
/*=============================================
[ Animation Classes ]
==============================================*/
.fire {
display: none;
animation-delay: 0s;
fill-opacity: 1;
animation-timing-function: ease-in;
stroke-width: 0px;
animation-iteration-count: infinite;
animation-timing-function: linear;
transform-origin: 50% 50%;
animation-direction: normal;
}
.rocket_wrap:hover #fireLeft {
display: block;
animation-delay: 0s;
animation-name: fireLeft, fillOpacity1;
animation-duration: 1.2s;
}
.rocket_wrap:hover #fireMiddle {
display: block;
animation-delay: 0s;
animation-name: fireMiddle, fillOpacity1;
animation-duration: 1s;
}
.rocket_wrap:hover #fireRight {
display: block;
animation-delay: 0s;
animation-name: fireRight, fillOpacity1;
animation-duration: 1.3s;
}
.rocket_wrap:hover #fireSmallLeft {
display: block;
animation-delay: 0s;
animation-name: fireSmall, fillOpacity2;
animation-duration: 1.3s;
transform-origin: bottom;
}
.rocket_wrap:hover #fireSmallRight {
display: block;
animation-delay: 0.3s;
animation-name: fireSmall, fillOpacity3;
animation-duration: 1.6s;
transform-origin: bottom;
}
/*=============================================
[ KeyFrame Animations ]
==============================================*/
#keyframes fireSmall {
10% {
transform: rotate(17deg) translateY(1px)
}
20% {
transform: rotate(-13deg) translateY(2px)
}
30% {
transform: rotate(21deg) translateY(3px)
}
40% {
transform: rotate(-34deg)translateY(4px)
}
50% {
transform: rotate(24deg) translateY(5px)
}
60% {
transform: rotate(-17deg) translateY(6px)
}
70% {
transform: rotate(31deg) translateY(7px)
}
80% {
transform: rotate(-28deg) translateY(8px)
}
90% {
transform: rotate(14deg) translateY(9px)
}
99% {
transform: rotate(0deg) translateY(10px)
}
}
#keyframes fireLeft {
6% {
transform: rotate(25deg)
}
15% {
transform: rotate(-19deg)
}
25% {
transform: rotate(25deg)
}
32% {
transform: rotate(-30deg)
}
46% {
transform: rotate(22deg)
}
54% {
transform: rotate(-29deg)
}
61% {
transform: rotate(32deg)
}
74% {
transform: rotate(-9deg)
}
83% {
transform: rotate(16deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fireMiddle {
10% {
transform: rotate(25deg)
}
20% {
transform: rotate(-25deg)
}
30% {
transform: rotate(30deg)
}
40% {
transform: rotate(-22deg)
}
50% {
transform: rotate(29deg)
}
60% {
transform: rotate(-45deg)
}
70% {
transform: rotate(37deg)
}
80% {
transform: rotate(-15deg)
}
90% {
transform: rotate(16deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fireRight {
15% {
transform: rotate(17deg)
}
23% {
transform: rotate(-13deg)
}
37% {
transform: rotate(21deg)
}
45% {
transform: rotate(-34deg)
}
54% {
transform: rotate(24deg)
}
67% {
transform: rotate(-17deg)
}
72% {
transform: rotate(31deg)
}
84% {
transform: rotate(-28deg)
}
96% {
transform: rotate(14deg)
}
99% {
transform: rotate(0deg)
}
}
#keyframes fillOpacity1 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
50% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes fillOpacity2 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
25% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes fillOpacity3 {
0% {
fill-opacity: 1;
stroke-opacity: 1;
}
67% {
fill-opacity: 1;
stroke-opacity: 1;
}
100% {
fill-opacity: 0;
stroke-opacity: 0;
}
}
#keyframes rocektMove {
0% {
transform: translateY(0px)
}
100% {
transform: translateY(20px)
}
}
<!-- http://www.pencilscoop.com/2013/11/animate-svg-icons-with-css3-jquery/ -->
<div id="pageWrap">
<div class="svg-container">
<svg version="1.1" x="0px" y="0px" viewBox="0 0 307 283" preserveAspectRatio="xMinYMin meet" id="rocket">
<g class="rocket_wrap">
<circle cx="147.5" cy="138.6" r="105.5" class="icon_circle" />
<g class="rocket_inner">
<path class="fire fire_path" id="fireMiddle" d="M148.891,179.906c3.928,0,7.111,3.176,7.111,7.094 c0,7.78-7.111,16-7.111,16s-7.111-8.349-7.111-16C141.78,183.082,144.963,179.906,148.891,179.906z" />
<path class="fire_path fire" id="fireRight" d="M154.063,181.092c3.577-1.624,7.788-0.048,9.408,3.52 c3.216,7.084,0.139,17.508,0.139,17.508s-9.927-4.662-13.09-11.63C148.9,186.923,150.487,182.715,154.063,181.092z" />
<path class="fire_path fire" id="fireLeft" d="M143.392,182.519c3.25,2.207,4.098,6.623,1.896,9.864 c-4.372,6.436-14.873,9.238-14.873,9.238s-1.191-10.902,3.108-17.23C135.725,181.149,140.143,180.312,143.392,182.519z" />
<path class="fire_path fire" id="fireSmallLeft" d="M143.193 187.531c2.226 0.4 3.7 2.6 3.2 4.8 c-0.875 4.407-5.829 8.264-5.829 8.264s-3.09-5.53-2.229-9.865C138.807 188.5 141 187.1 143.2 187.531z" />
<path class="fire_path fire" id="fireSmallRight" d="M152.089 188.599c2.043-0.985 4.496-0.132 5.5 1.9 c1.952 4 0.3 10.1 0.3 10.107s-5.795-2.56-7.713-6.541C149.186 192 150 189.6 152.1 188.599z" />
<path class="rocket_bottom" d="M157.069 171.31h-3.292c-1.562-0.048-3.178-0.076-4.846-0.076 s-3.284 0.028-4.846 0.076h-3.292c-7.277-7.938-12.371-26.182-12.371-47.434c0-28.54 9.182-51.676 20.508-51.676 c11.327 0 20.5 23.1 20.5 51.676C169.44 145.1 164.3 163.4 157.1 171.31z"
/>
<g id="right_wing_wrap">
<path class="wing_base" d="M166.678 127.161c0 0 17.7 3.3 12.9 48.099l-18.06-14.05 L166.678 127.161z" />
<path class="wing_shadow" d="M158.225 140.336c10.481-5.584 22.7 22.2 21.4 34.9 l-18.06-14.05C161.542 161.2 156.1 144.3 158.2 140.336z" />
</g>
<g id="left_wing_wrap">
<path class="wing_base" d="M135.131 161.21l-18.06 14.1 c-4.805-44.793 12.924-48.099 12.924-48.099L135.131 161.21z" />
<path class="wing_shadow" d="M135.131 161.21l-18.06 14.1 c-1.367-12.746 10.896-40.509 21.377-34.924C140.614 144.3 135.1 161.2 135.1 161.21z" />
</g>
<g id="rocket_body_wrap">
<path class="rocket_base" d="M162.728 167.358c-3.778-0.623-8.573-0.996-13.796-0.996 s-10.018 0.373-13.795 0.996c-5.033-10.186-8.257-25.808-8.257-43.338c0-30.688 9.873-55.566 22.052-55.566 s22.053 24.9 22.1 55.566C170.984 141.6 167.8 157.2 162.7 167.358z"
/>
<path class="rocket_shadow" d="M145.464 166.417c19.578-40.575 7.26-85.229 4.112-98.067 c11.88 0.9 21.4 25.4 21.4 55.525c0 17.529-3.225 33.152-8.257 43.337c0 0-3.786-0.472-8.069-0.697 S145.464 166.4 145.5 166.417z" />
</g>
<g id="large_window_wrap">
<radialgradient id="SVGID_2_" cx="148.9" cy="112.5" r="15.2" fx="139.4853" fy="112.5239" gradientunits="userSpaceOnUse">
<stop offset="0" class="window_grandient" />
<stop offset="0.5868" class="window_grandient" />
<stop offset="0.6834" class="window_grandient" />
<stop offset="0.6845" class="window_grandient1" />
<stop offset="0.6861" class="window_grandient2" />
<stop offset="0.6897" class="window_grandient3" />
</radialgradient>
<circle class="large_window_path" cx="148.9" cy="111.3" r="10.5" />
</g>
<circle class="small_window_path" cx="148.9" cy="132.4" r="5.2" />
</g>
</g>
</svg>
</div>
</div>