SVG transform origin differences in FireFox / Chrome [duplicate] - css

This question already has answers here:
transform-origin not working in Firefox even properties in percentage value
(3 answers)
Closed 6 years ago.
Here is my character animation I was working on, which is working fine in Chrome but in FireFox it's kind of mess because FireFox has a different method of calculating transform origin related to the SVG canvas itself not to the group object.
.st0 {
fill: #30363f;
}
.st1 {
fill: #dba897;
}
.st2 {
fill: #e2e2e2;
}
.st3 {
fill: #1f2329;
}
.st4 {
fill: #60562b;
}
.st5 {
fill: #bf9286;
}
.st6 {
fill: #251b1b;
}
.st7 {
fill: #2d1c1c;
}
.st8 {
fill: #fff;
}
.st9 {
fill: #46ba7c;
}
.st10 {
fill: #ccc;
}
svg {
display: block;
max-width: 400px;
margin: auto;
}
g {
-webkit-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
#head {
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
-webkit-animation: head-rotate 10s infinite;
animation: head-rotate 10s infinite;
}
#arm-l {
-webkit-transform-origin: 80% 2%;
transform-origin: 80% 2%;
-webkit-animation: arm-anger 5s infinite;
animation: arm-anger 5s infinite;
}
#hand-l {
-webkit-transform-origin: 70% 12%;
transform-origin: 70% 12%;
-webkit-animation: hand-anger 5s infinite;
animation: hand-anger 5s infinite;
}
#desk {
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
-webkit-animation: desk-anger 5s infinite;
animation: desk-anger 5s infinite;
}
#eye-r,
#eye-l {
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
-webkit-animation: eye-blinking 10s infinite;
animation: eye-blinking 10s infinite;
}
#arm-r {
-webkit-transform-origin: 30% 2%;
transform-origin: 30% 2%;
}
#hand-r {
-webkit-transform-origin: 30% 12%;
transform-origin: 30% 12%;
}
#-webkit-keyframes head-rotate {
0% {
-webkit-transform: rotate(4deg);
transform: rotate(4deg);
}
50% {
-webkit-transform: rotate(-4deg);
transform: rotate(-4deg);
}
100% {
-webkit-transform: rotate(5deg);
transform: rotate(5deg);
}
}
#keyframes head-rotate {
0% {
-webkit-transform: rotate(4deg);
transform: rotate(4deg);
}
50% {
-webkit-transform: rotate(-4deg);
transform: rotate(-4deg);
}
100% {
-webkit-transform: rotate(5deg);
transform: rotate(5deg);
}
}
#-webkit-keyframes arm-anger {
0% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
5% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
10% {
-webkit-transform: rotate(10deg);
transform: rotate(10deg);
}
15% {
-webkit-transform: rotate(20deg);
transform: rotate(20deg);
}
20% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
}
#keyframes arm-anger {
0% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
5% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
10% {
-webkit-transform: rotate(10deg);
transform: rotate(10deg);
}
15% {
-webkit-transform: rotate(20deg);
transform: rotate(20deg);
}
20% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
}
#-webkit-keyframes hand-anger {
0% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
5% {
-webkit-transform: rotate(50deg);
transform: rotate(50deg);
}
10% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
15% {
-webkit-transform: rotate(30deg);
transform: rotate(30deg);
}
20% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
}
#keyframes hand-anger {
0% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
5% {
-webkit-transform: rotate(50deg);
transform: rotate(50deg);
}
10% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
15% {
-webkit-transform: rotate(30deg);
transform: rotate(30deg);
}
20% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
}
#-webkit-keyframes desk-anger {
9% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
10% {
-webkit-transform: rotate(-2deg);
transform: rotate(-2deg);
}
13% {
-webkit-transform: rotate(1deg);
transform: rotate(1deg);
}
15% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
}
#keyframes desk-anger {
9% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
10% {
-webkit-transform: rotate(-2deg);
transform: rotate(-2deg);
}
13% {
-webkit-transform: rotate(1deg);
transform: rotate(1deg);
}
15% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
}
#-webkit-keyframes eye-blinking {
0% {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
1% {
-webkit-transform: scaleY(0.1);
transform: scaleY(0.1);
}
2% {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
}
#keyframes eye-blinking {
0% {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
1% {
-webkit-transform: scaleY(0.1);
transform: scaleY(0.1);
}
2% {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
}
<svg version="1.1" id="character_1" viewBox="0 0 1024 1024" preserveAspectRatio="xMinYMin meet">
<g id="body">
<g id="arm-r">
<path id="upperArm-r" class="st0" d="M582.7,804.3L582.7,804.3c-7.3,2.1-14.8-2-17-9.3l-24.2-82.9l26.3-7.7l24.2,82.9
C594.1,794.5,590,802.1,582.7,804.3z" />
<g id="hand-r">
<path class="st1" d="M604.4,857.2l-1.9-6.6l-11.2,3.3l1.9,6.6c-3.8,3.4-5.6,8.8-4.1,14.1c2.1,7.3,9.7,11.4,17,9.3
s11.4-9.7,9.3-17C613.8,861.7,609.4,858,604.4,857.2z" />
<rect x="584.1" y="847.1" transform="matrix(0.9598 -0.2806 0.2806 0.9598 -214.7713 201.5524)" class="st2" width="24.6" height="7.1" />
<path class="st0" d="M607.8,841l-26.3,7.7l-15.6-53.4c-2.1-7.3,2-14.8,9.3-17v0c7.3-2.1,14.8,2,17,9.3L607.8,841z" />
<rect x="578.9" y="839.8" transform="matrix(0.9598 -0.2806 0.2806 0.9598 -213.2036 200.8397)" class="st3" width="31.5" height="10.1" />
</g>
</g>
<g id="arm-l">
<path id="upperArm-l" class="st0" d="M441,804.3L441,804.3c7.3,2.1,14.8-2,17-9.3l24.2-82.9l-26.3-7.7l-24.2,82.9
C429.6,794.5,433.8,802.1,441,804.3z" />
<g id="hand-l">
<path class="st1" d="M419.4,857.2l1.9-6.6l11.2,3.3l-1.9,6.6c3.8,3.4,5.6,8.8,4.1,14.1c-2.1,7.3-9.7,11.4-17,9.3
c-7.3-2.1-11.4-9.7-9.3-17C409.9,861.7,414.3,858,419.4,857.2z" />
<rect x="415.1" y="847.1" transform="matrix(-0.9598 -0.2806 0.2806 -0.9598 598.7922 1787.1604)" class="st2" width="24.6" height="7.1" />
<path class="st0" d="M415.9,841l26.3,7.7l15.6-53.4c2.1-7.3-2-14.8-9.3-17l0,0c-7.3-2.1-14.8,2-17,9.3L415.9,841z" />
<rect x="413.3" y="839.8" transform="matrix(-0.9598 -0.2806 0.2806 -0.9598 603.7693 1776.2122)" class="st3" width="31.5" height="10.1" />
</g>
</g>
<g id="clothes">
<polygon class="st2" points="520.7,864.7 520.7,683.9 503.3,683.9 503.3,864.7 456.2,864.7 456.2,874.2 567.8,874.2 567.8,864.7
" />
<path class="st3" d="M531.7,681.8c0,3.5-5.7,6.4-13.5,7.4c-1.9,0.3-4,0.4-6.1,0.4c-2.1,0-4.2-0.1-6.1-0.4c-7.9-1-13.5-4-13.5-7.4
c0-4.3,8.8-7.8,19.7-7.8C522.9,674,531.7,677.5,531.7,681.8z" />
<ellipse class="st2" cx="512" cy="685.3" rx="13.4" ry="5.4" />
<path class="st0" d="M505.9,689.3c-7.9-1-13.5-4-13.5-7.4V693l-36.1,11.3v160.4h47V704.2h2.6V689.3z" />
<path class="st0" d="M531.7,693v-11.2c0,3.5-5.7,6.4-13.5,7.4v14.9h2.6v160.5h47V704.3L531.7,693z" />
<circle class="st4" cx="512" cy="751.9" r="1.8" />
<circle class="st4" cx="512.1" cy="722.5" r="1.8" />
<circle class="st4" cx="512" cy="781.3" r="1.8" />
<circle class="st4" cx="512" cy="810.7" r="1.8" />
<circle class="st4" cx="512" cy="840.1" r="1.8" />
<path class="st5" d="M500.2,664.4v18.8c0,2.6,5.3,4.7,11.8,4.7c6.5,0,11.8-2.1,11.8-4.7v-18.8H500.2z" />
</g>
</g>
<g id="head">
<path id="ear-r" class="st1" d="M638.2,511.8h-8.7v-76.4h8.7c9.8,0,17.7,7.9,17.7,17.7v41.1C655.8,503.9,647.9,511.8,638.2,511.8z" />
<path id="ear-l" class="st1" d="M385.8,511.8h8.7v-76.4h-8.7c-9.8,0-17.7,7.9-17.7,17.7v41.1C368.2,503.9,376.1,511.8,385.8,511.8z
" />
<path id="face" class="st1" d="M386.5,316.8v255.9c0,5,1.5,9.9,4.3,14.1l58.7,72.5c7.8,9.6,19.5,15.2,31.9,15.2h61.3
c12.4,0,24.1-5.6,31.9-15.2l58.7-72.5c2.8-4.2,4.3-9.1,4.3-14.1V316.8H386.5z" />
<polygon id="eyebrow-r" class="st6" points="595.2,463.9 521.3,480.2 591.1,451.2 " />
<g id="eye-r">
<circle class="st7" cx="558.3" cy="505.3" r="15.7" />
<circle class="st8" cx="551.1" cy="498.1" r="4.4" />
</g>
<polygon id="eyebrow-l" class="st6" points="437.8,441.2 502.5,480.2 431.9,453.2 " />
<g id="eye-l">
<circle class="st7" cx="465.7" cy="505.3" r="15.7" />
<circle class="st8" cx="457.9" cy="497.4" r="3.8" />
</g>
<path id="hair" class="st6" d="M625.8,293.2c-4.1-0.3-7.9,1.5-10.3,4.3c-1.6,1.8-4.5,1.9-6.1,0c-2.3-2.7-5.7-4.4-9.5-4.4
s-7.2,1.7-9.5,4.4c-1.6,1.8-4.5,1.8-6,0c-2.3-2.7-5.7-4.4-9.5-4.4c-3.8,0-7.2,1.7-9.5,4.4c-1.6,1.8-4.5,1.8-6,0
c-2.3-2.7-5.7-4.4-9.5-4.4s-7.2,1.7-9.5,4.4c-1.6,1.8-4.5,1.8-6,0c-2.3-2.7-5.7-4.4-9.5-4.4s-7.2,1.7-9.5,4.4c-1.6,1.8-4.5,1.8-6,0
c-2.3-2.7-5.7-4.4-9.5-4.4c-3.8,0-7.2,1.7-9.5,4.4c-1.6,1.8-4.5,1.8-6,0c-2.3-2.7-5.7-4.4-9.5-4.4c-3.8,0-7.2,1.7-9.5,4.4
c-1.6,1.8-4.5,1.8-6,0c-2.3-2.7-5.7-4.4-9.5-4.4s-7.2,1.7-9.5,4.4c-1.6,1.8-4.5,1.8-6,0c-2.3-2.7-5.7-4.4-9.5-4.4s-7.2,1.7-9.5,4.4
c-1.6,1.8-4.5,1.8-6.1,0c-2.5-2.9-6.2-4.6-10.3-4.3c-6.7,0.4-11.7,6.3-11.7,13v1.5v7.6v35.3v83.7V476H399v-41.8l12.6-12.6v-67.3
c0-2.1,1.7-3.8,3.8-3.8h193.2c2.1,0,3.8,1.7,3.8,3.8v67.3l12.6,12.6V476h12.6v-41.8v-83.7v-35.3v-7.6v-1.5
C637.5,299.5,632.5,293.6,625.8,293.2z" />
<polygon id="mouth" class="st8" points="460.1,600.5 562.6,601 563.9,578 461.7,592.5 " />
</g>
<rect id="desk" x="166" y="867.8" class="st9" width="692" height="25.8" />
<g id="laptop">
<polygon class="st10" points="627.6,738.7 396.4,738.7 402.4,873.3 621.6,873.3 " />
<circle class="st8" cx="510.4" cy="811.4" r="22.2" />
</g>
</svg>
Here is the question is there is a way that i can make FireFox behave like Chrome or reverse Chrome act like FireFox so my animation can run on cross browsers.

When i used absolute values instead of percentage it worked fine
for instance change transform-origin: 50% 50% to transform-origin: 512px 660px
The working code
See the Pen Just developing by Abdelrahman Ismail (#ismail9k) on CodePen.

Related

CSS Animation Currently Only working in Firefox, not Chrome or Safari

Currently working on a simple animation to show a slide being inserted into a viewmaster.
it works in firefox, but not chrome or safari. I haven't tested other browsers yet. I've included -webkit-animation as well as #-webkit-keyframes. I've been trying to find other similar questions, but no luck so far.
html,
body {
width: 100%;
height: 100%;
background-color: #F2EFEB;
}
.intro-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 80%;
}
.logo-bottom,
.logo-top {
display: inline-block;
position: relative;
}
.logo-bottom {
-o-animation: logo-anim-bottom 1.5s;
-ms-animation: logo-anim-bottom 1.5s;
-moz-animation: logo-anim-bottom 1.5s;
-webkit-animation: logo-anim-bottom 1.5s infinite;
animation: logo-anim-bottom 1.5s infinite;
}
.logo-top {
-o-animation: logo-anim-top 1.5;
-ms-animation: logo-anim-top 1.5;
-moz-animation: logo-anim-top 1.5s;
-webkit-animation: logo-anim-top 1.5 infinite;
animation: logo-anim-top 1.5s infinite;
}
#-ms-keyframes logo-anim-bottom {
0% {
top: 0;
}
26% {
top: 0;
}
29% {
top: 15px;
}
40% {
top: 0;
}
}
#-o-keyframes logo-anim-bottom {
0% {
top: 0;
}
26% {
top: 0;
}
29% {
top: 15px;
}
40% {
top: 0;
}
}
#-moz-keyframes logo-anim-bottom {
0% {
top: 0;
}
26% {
top: 0;
}
29% {
top: 15px;
}
40% {
top: 0;
}
}
#-ms-keyframes logo-anim-bottom {
0% {
top: 0;
}
26% {
top: 0;
}
29% {
top: 15px;
}
40% {
top: 0;
}
}
#-webkit-keyframes logo-anim-bottom {
0% {
top: 0;
}
26% {
top: 0;
}
29% {
top: 15px;
}
40% {
top: 0;
}
}
#keyframes logo-anim-bottom {
0% {
top: 0;
}
26% {
top: 0;
}
29% {
top: 15px;
}
40% {
top: 0;
}
}
#-ms-keyframes logo-anim-top {
0% {
top: -55px;
}
25% {
top: -75px;
}
30% {
top: 15px;
}
40% {
top: 0;
}
}
#-o-keyframes logo-anim-top {
0% {
top: -55px;
}
25% {
top: -75px;
}
30% {
top: 15px;
}
40% {
top: 0;
}
}
#-moz-keyframes logo-anim-top {
0% {
top: -55px;
}
25% {
top: -75px;
}
30% {
top: 15px;
}
40% {
top: 0;
}
}
#-ms-keyframes logo-anim-top {
0% {
top: -55px;
}
25% {
top: -75px;
}
30% {
top: 15px;
}
40% {
top: 0;
}
}
#-webkit-keyframes logo-anim-top {
0% {
top: -55px;
}
25% {
top: -75px;
}
30% {
top: 15px;
}
40% {
top: 0;
}
}
#keyframes logo-anim-top {
0% {
top: -55px;
}
25% {
top: -75px;
}
30% {
top: 15px;
}
40% {
top: 0;
}
}
.red {
fill: #E491C5;
}
.yellow {
fill: #FDF388;
}
.dark-yellow {
fill: #e0d580;
}
.brown {
fill: #633E17;
}
.pure-white {
fill: #ffffff;
}
.dark-grey {
fill: #30332a;
}
.white {
fill: #F2EFEB;
}
.black {
fill: #181914;
}
<div class="intro-container">
<div class="animate__animated animate__fadeOut animate__fast animate__delay-1s">
<svg width="250px" height="350px" viewBox="0 0 250 350" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="slide" class="logo-top">
<circle class="pure-white" cx="126.01" cy="205.99" r="61.21"/>
<path class="dark-grey" d="M134.27,154.76v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C133.12,152.2,134.27,153.34,134.27,154.76z"/>
<path class="dark-grey" d="M158.9,163.6l-4.31,10.55c-0.54,1.31-2.03,1.94-3.34,1.4l-10.55-4.31c-1.31-0.54-1.94-2.03-1.4-3.34
l4.31-10.55c0.54-1.31,2.03-1.94,3.34-1.4l10.55,4.31C158.81,160.79,159.44,162.29,158.9,163.6z"/>
<path class="dark-grey" d="M134.27,244.97v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C133.12,242.41,134.27,243.56,134.27,244.97z"/>
<path class="dark-grey" d="M88.35,200.3v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C87.2,197.73,88.35,198.88,88.35,200.3z"/>
<path class="dark-grey" d="M178.45,200.3v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C177.31,197.73,178.45,198.88,178.45,200.3z"/>
<path class="dark-grey" d="M170.99,174.6l4.56,10.45c0.57,1.3-0.03,2.81-1.32,3.37l-10.45,4.56c-1.3,0.57-2.81-0.03-3.37-1.32
l-4.56-10.45c-0.57-1.3,0.03-2.81,1.32-3.37l10.45-4.56C168.91,172.71,170.42,173.3,170.99,174.6z"/>
<path class="dark-grey" d="M96.16,174.53l-4.31-10.55c-0.54-1.31,0.09-2.81,1.4-3.34l10.55-4.31c1.31-0.54,2.81,0.09,3.34,1.4
l4.31,10.55c0.54,1.31-0.09,2.81-1.4,3.34l-10.55,4.31C98.19,176.46,96.7,175.84,96.16,174.53z"/>
<path class="dark-grey" d="M75.24,185.43l4.56-10.45c0.57-1.3,2.08-1.89,3.37-1.32l10.45,4.56c1.3,0.57,1.89,2.08,1.32,3.37l-4.56,10.45
c-0.57,1.3-2.08,1.89-3.37,1.32l-10.45-4.56C75.27,188.24,74.68,186.73,75.24,185.43z"/>
<path class="dark-grey" d="M93.43,247.92l4.31-10.55c0.54-1.31,2.03-1.94,3.34-1.4l10.55,4.31c1.31,0.54,1.94,2.03,1.4,3.34l-4.31,10.55
c-0.54,1.31-2.03,1.94-3.34,1.4l-10.55-4.31C93.52,250.72,92.89,249.23,93.43,247.92z"/>
<path class="dark-grey" d="M81.34,236.92l-4.56-10.45c-0.57-1.3,0.03-2.81,1.32-3.37l10.45-4.56c1.3-0.57,2.81,0.03,3.37,1.32
l4.56,10.45c0.57,1.3-0.03,2.81-1.32,3.37l-10.45,4.56C83.42,238.81,81.91,238.21,81.34,236.92z"/>
<path class="dark-grey" d="M154.29,237.9l4.31,10.55c0.54,1.31-0.09,2.81-1.4,3.34l-10.55,4.31c-1.31,0.54-2.81-0.09-3.34-1.4
l-4.31-10.55c-0.54-1.31,0.09-2.81,1.4-3.34l10.55-4.31C152.25,235.96,153.75,236.58,154.29,237.9z"/>
<path class="dark-grey" d="M175.22,226.99l-4.56,10.45c-0.57,1.3-2.08,1.89-3.37,1.32l-10.45-4.56c-1.3-0.57-1.89-2.08-1.32-3.37
l4.56-10.45c0.57-1.3,2.08-1.89,3.37-1.32l10.45,4.56C175.19,224.18,175.78,225.69,175.22,226.99z"/>
</g>
<g id="viewmaster" class="logo-bottom">
<g>
<path class="yellow" d="M212.43,184.86c2.66,6.89,8.95,11.97,16.53,12.9c-2.38,2.14-5.03,3.61-7.25,4.59
c-2.78-2.16-6.23-3.52-10.01-3.68c-0.61-0.08-1.22-0.14-1.83-0.21l-0.64-12.25C210.33,185.81,211.39,185.36,212.43,184.86z"/>
<path class="yellow" d="M213.71,177.53L213.71,177.53c0-9.79,7.94-17.73,17.73-17.73s17.73,7.94,17.73,17.73s-7.94,17.73-17.73,17.73
C221.66,195.26,213.73,187.32,213.71,177.53z M231.45,171.37c-3.41-0.01-6.18,2.75-6.18,6.16c0,3.4,2.75,6.15,6.14,6.16
c3.4,0.01,6.17-2.74,6.18-6.14C237.6,174.15,234.85,171.38,231.45,171.37L231.45,171.37z"/>
<path class="dark-yellow" d="M217.81,177.53C217.81,177.53,217.81,177.53,217.81,177.53c0-7.53,6.11-13.64,13.64-13.64
s13.64,6.11,13.64,13.64c0,7.53-6.11,13.64-13.64,13.64C223.92,191.17,217.81,185.06,217.81,177.53z M221.2,177.53
c0,0.01,0,0.01,0,0.02c0.01,5.67,4.62,10.26,10.29,10.25c5.67-0.01,10.26-4.62,10.25-10.29c-0.01-5.67-4.62-10.26-10.29-10.25
C225.79,167.28,221.2,171.87,221.2,177.53z"/>
<circle class="yellow" cx="231.45" cy="177.53" r="11.95"/>
</g>
<path class="red" d="M44.2,198.19c0.21-4.59,0.58-12.6,0.88-18.43c0.46-8.64,4.42-11.11,6.96-12.67
c2.54-1.56,17.14-0.91,28.13-0.91c11.95,7.02,28.25,9.14,45.84,9.75c17.59-0.64,33.89-2.73,45.83-9.75c11,0,25.6-0.64,28.14,0.91
c2.54,1.55,6.5,4.06,6.95,12.67c0.3,5.81,0.66,13.83,0.86,18.43C153.45,191.72,98.54,191.72,44.2,198.19z"/>
<path class="red" d="M207.85,256.46c-0.89,14.56-6.66,47.82-8.56,52.07c-2.08,4.67-8.12,5.2-8.12,5.2H60.86
c0,0-6.09-0.52-8.12-5.2c-1.85-4.26-7.66-37.51-8.57-52.06c27.09,3.22,54.34,4.85,81.63,4.84
C153.22,261.3,180.62,259.67,207.85,256.46z"/>
<path class="red" d="M25.89,216.15v22.34c0.01,8.14,6.46,14.82,14.59,15.11c28.3,3.53,56.79,5.29,85.31,5.29
c28.66,0,57.29-1.77,85.73-5.29c8.14-0.29,14.59-6.97,14.59-15.11v-22.34c-0.01-8.14-6.46-14.81-14.59-15.1
c-56.79-7.11-114.24-7.11-171.03,0C32.35,201.33,25.9,208.01,25.89,216.15z M33.16,216.16c0.02-4.35,3.54-7.87,7.89-7.88
c56.44-7.13,113.55-7.13,169.99,0c4.33,0.03,7.83,3.54,7.85,7.87v22.34c-0.02,4.35-3.54,7.87-7.89,7.89
c-56.44,7.08-113.55,7.08-169.99,0c-4.33-0.04-7.83-3.55-7.85-7.88V216.16z"/>
<path id="_x3C_Path_x3E_" class="dark-grey" d="M41.06,208.28c56.44-7.13,113.55-7.13,169.99,0c4.33,0.03,7.83,3.54,7.85,7.87v22.34
c-0.02,4.35-3.54,7.87-7.89,7.89c-56.44,7.08-113.55,7.08-169.99,0c-4.33-0.04-7.83-3.55-7.85-7.88v-22.34
C33.18,211.81,36.71,208.29,41.06,208.28z"/>
</g>
</svg>
</div>
</div>
You can use tranform translateY() instead of top values and it should work cross-browser. Pretty sure Chrome does not respect the position relative for child SVG elements.
html,
body {
width: 100%;
height: 100%;
background-color: #F2EFEB;
}
.intro-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 80%;
}
.logo-bottom,
.logo-top {
display: inline-block;
position: relative;
}
.logo-bottom {
-o-animation: logo-anim-bottom 1.5s;
-ms-animation: logo-anim-bottom 1.5s;
-moz-animation: logo-anim-bottom 1.5s;
-webkit-animation: logo-anim-bottom 1.5s infinite;
animation: logo-anim-bottom 1.5s infinite;
}
.logo-top {
-o-animation: logo-anim-top 1.5;
-ms-animation: logo-anim-top 1.5;
-moz-animation: logo-anim-top 1.5s;
-webkit-animation: logo-anim-top 1.5 infinite;
animation: logo-anim-top 1.5s infinite;
}
#-ms-keyframes logo-anim-bottom {
0% {
transform: translateY(0)
}
26% {
transform: translateY(0)
}
29% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#-o-keyframes logo-anim-bottom {
0% {
transform: translateY(0)
}
26% {
transform: translateY(0)
}
29% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#-moz-keyframes logo-anim-bottom {
0% {
transform: translateY(0)
}
26% {
transform: translateY(0)
}
29% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#-webkit-keyframes logo-anim-bottom {
0% {
transform: translateY(0)
}
26% {
transform: translateY(0)
}
29% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#keyframes logo-anim-bottom {
0% {
transform: translateY(0)
}
26% {
transform: translateY(0)
}
29% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#-ms-keyframes logo-anim-top {
0% {
transform: translateY(-55px)
}
25% {
transform: translateY(-75px)
}
30% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#-o-keyframes logo-anim-top {
0% {
transform: translateY(-55px)
}
25% {
transform: translateY(-75px)
}
30% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#-moz-keyframes logo-anim-top {
0% {
transform: translateY(-55px)
}
25% {
transform: translateY(-75px)
}
30% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#-webkit-keyframes logo-anim-top {
0% {
transform: translateY(-55px)
}
25% {
transform: translateY(-75px)
}
30% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
#keyframes logo-anim-top {
0% {
transform: translateY(-55px)
}
25% {
transform: translateY(-75px)
}
30% {
transform: translateY(15px)
}
40% {
transform: translateY(0)
}
}
.red {
fill: #E491C5;
}
.yellow {
fill: #FDF388;
}
.dark-yellow {
fill: #e0d580;
}
.brown {
fill: #633E17;
}
.pure-white {
fill: #ffffff;
}
.dark-grey {
fill: #30332a;
}
.white {
fill: #F2EFEB;
}
.black {
fill: #181914;
}
<div class="intro-container">
<div class="animate__animated animate__fadeOut animate__fast animate__delay-1s">
<svg width="250px" height="350px" viewBox="0 0 250 350" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="slide" class="logo-top">
<circle class="pure-white" cx="126.01" cy="205.99" r="61.21"/>
<path class="dark-grey" d="M134.27,154.76v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C133.12,152.2,134.27,153.34,134.27,154.76z"/>
<path class="dark-grey" d="M158.9,163.6l-4.31,10.55c-0.54,1.31-2.03,1.94-3.34,1.4l-10.55-4.31c-1.31-0.54-1.94-2.03-1.4-3.34
l4.31-10.55c0.54-1.31,2.03-1.94,3.34-1.4l10.55,4.31C158.81,160.79,159.44,162.29,158.9,163.6z"/>
<path class="dark-grey" d="M134.27,244.97v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C133.12,242.41,134.27,243.56,134.27,244.97z"/>
<path class="dark-grey" d="M88.35,200.3v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C87.2,197.73,88.35,198.88,88.35,200.3z"/>
<path class="dark-grey" d="M178.45,200.3v11.4c0,1.42-1.15,2.56-2.56,2.56h-11.4c-1.42,0-2.56-1.15-2.56-2.56v-11.4
c0-1.42,1.15-2.56,2.56-2.56h11.4C177.31,197.73,178.45,198.88,178.45,200.3z"/>
<path class="dark-grey" d="M170.99,174.6l4.56,10.45c0.57,1.3-0.03,2.81-1.32,3.37l-10.45,4.56c-1.3,0.57-2.81-0.03-3.37-1.32
l-4.56-10.45c-0.57-1.3,0.03-2.81,1.32-3.37l10.45-4.56C168.91,172.71,170.42,173.3,170.99,174.6z"/>
<path class="dark-grey" d="M96.16,174.53l-4.31-10.55c-0.54-1.31,0.09-2.81,1.4-3.34l10.55-4.31c1.31-0.54,2.81,0.09,3.34,1.4
l4.31,10.55c0.54,1.31-0.09,2.81-1.4,3.34l-10.55,4.31C98.19,176.46,96.7,175.84,96.16,174.53z"/>
<path class="dark-grey" d="M75.24,185.43l4.56-10.45c0.57-1.3,2.08-1.89,3.37-1.32l10.45,4.56c1.3,0.57,1.89,2.08,1.32,3.37l-4.56,10.45
c-0.57,1.3-2.08,1.89-3.37,1.32l-10.45-4.56C75.27,188.24,74.68,186.73,75.24,185.43z"/>
<path class="dark-grey" d="M93.43,247.92l4.31-10.55c0.54-1.31,2.03-1.94,3.34-1.4l10.55,4.31c1.31,0.54,1.94,2.03,1.4,3.34l-4.31,10.55
c-0.54,1.31-2.03,1.94-3.34,1.4l-10.55-4.31C93.52,250.72,92.89,249.23,93.43,247.92z"/>
<path class="dark-grey" d="M81.34,236.92l-4.56-10.45c-0.57-1.3,0.03-2.81,1.32-3.37l10.45-4.56c1.3-0.57,2.81,0.03,3.37,1.32
l4.56,10.45c0.57,1.3-0.03,2.81-1.32,3.37l-10.45,4.56C83.42,238.81,81.91,238.21,81.34,236.92z"/>
<path class="dark-grey" d="M154.29,237.9l4.31,10.55c0.54,1.31-0.09,2.81-1.4,3.34l-10.55,4.31c-1.31,0.54-2.81-0.09-3.34-1.4
l-4.31-10.55c-0.54-1.31,0.09-2.81,1.4-3.34l10.55-4.31C152.25,235.96,153.75,236.58,154.29,237.9z"/>
<path class="dark-grey" d="M175.22,226.99l-4.56,10.45c-0.57,1.3-2.08,1.89-3.37,1.32l-10.45-4.56c-1.3-0.57-1.89-2.08-1.32-3.37
l4.56-10.45c0.57-1.3,2.08-1.89,3.37-1.32l10.45,4.56C175.19,224.18,175.78,225.69,175.22,226.99z"/>
</g>
<g id="viewmaster" class="logo-bottom">
<g>
<path class="yellow" d="M212.43,184.86c2.66,6.89,8.95,11.97,16.53,12.9c-2.38,2.14-5.03,3.61-7.25,4.59
c-2.78-2.16-6.23-3.52-10.01-3.68c-0.61-0.08-1.22-0.14-1.83-0.21l-0.64-12.25C210.33,185.81,211.39,185.36,212.43,184.86z"/>
<path class="yellow" d="M213.71,177.53L213.71,177.53c0-9.79,7.94-17.73,17.73-17.73s17.73,7.94,17.73,17.73s-7.94,17.73-17.73,17.73
C221.66,195.26,213.73,187.32,213.71,177.53z M231.45,171.37c-3.41-0.01-6.18,2.75-6.18,6.16c0,3.4,2.75,6.15,6.14,6.16
c3.4,0.01,6.17-2.74,6.18-6.14C237.6,174.15,234.85,171.38,231.45,171.37L231.45,171.37z"/>
<path class="dark-yellow" d="M217.81,177.53C217.81,177.53,217.81,177.53,217.81,177.53c0-7.53,6.11-13.64,13.64-13.64
s13.64,6.11,13.64,13.64c0,7.53-6.11,13.64-13.64,13.64C223.92,191.17,217.81,185.06,217.81,177.53z M221.2,177.53
c0,0.01,0,0.01,0,0.02c0.01,5.67,4.62,10.26,10.29,10.25c5.67-0.01,10.26-4.62,10.25-10.29c-0.01-5.67-4.62-10.26-10.29-10.25
C225.79,167.28,221.2,171.87,221.2,177.53z"/>
<circle class="yellow" cx="231.45" cy="177.53" r="11.95"/>
</g>
<path class="red" d="M44.2,198.19c0.21-4.59,0.58-12.6,0.88-18.43c0.46-8.64,4.42-11.11,6.96-12.67
c2.54-1.56,17.14-0.91,28.13-0.91c11.95,7.02,28.25,9.14,45.84,9.75c17.59-0.64,33.89-2.73,45.83-9.75c11,0,25.6-0.64,28.14,0.91
c2.54,1.55,6.5,4.06,6.95,12.67c0.3,5.81,0.66,13.83,0.86,18.43C153.45,191.72,98.54,191.72,44.2,198.19z"/>
<path class="red" d="M207.85,256.46c-0.89,14.56-6.66,47.82-8.56,52.07c-2.08,4.67-8.12,5.2-8.12,5.2H60.86
c0,0-6.09-0.52-8.12-5.2c-1.85-4.26-7.66-37.51-8.57-52.06c27.09,3.22,54.34,4.85,81.63,4.84
C153.22,261.3,180.62,259.67,207.85,256.46z"/>
<path class="red" d="M25.89,216.15v22.34c0.01,8.14,6.46,14.82,14.59,15.11c28.3,3.53,56.79,5.29,85.31,5.29
c28.66,0,57.29-1.77,85.73-5.29c8.14-0.29,14.59-6.97,14.59-15.11v-22.34c-0.01-8.14-6.46-14.81-14.59-15.1
c-56.79-7.11-114.24-7.11-171.03,0C32.35,201.33,25.9,208.01,25.89,216.15z M33.16,216.16c0.02-4.35,3.54-7.87,7.89-7.88
c56.44-7.13,113.55-7.13,169.99,0c4.33,0.03,7.83,3.54,7.85,7.87v22.34c-0.02,4.35-3.54,7.87-7.89,7.89
c-56.44,7.08-113.55,7.08-169.99,0c-4.33-0.04-7.83-3.55-7.85-7.88V216.16z"/>
<path id="_x3C_Path_x3E_" class="dark-grey" d="M41.06,208.28c56.44-7.13,113.55-7.13,169.99,0c4.33,0.03,7.83,3.54,7.85,7.87v22.34
c-0.02,4.35-3.54,7.87-7.89,7.89c-56.44,7.08-113.55,7.08-169.99,0c-4.33-0.04-7.83-3.55-7.85-7.88v-22.34
C33.18,211.81,36.71,208.29,41.06,208.28z"/>
</g>
</svg>
</div>
</div>

CSS3 Transform cutting off shape

I have a SVG rect that I am trying to animate to move vertically infinitely so that it looks like it's floating.
When the rect goes downwards, the bottom looks cut off and becomes thinner, and I can't seem to figure out how to make it so that the full SVG shape is still present while it moves.
Here is my JSFiddle
HTML:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 828 828" style="enable-background:new 0 0 828 828;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#000000;stroke-width:50;stroke-miterlimit:10;}
</style>
<rect id="box" x="26.9" y="26.1" class="st0" width="777.4" height="777.4"/>
</svg>
</div>
CSS:
.wrapper {
width:50%;
display:block;
margin-left:auto;
margin-right:auto;
margin:0 auto;
padding-top:5%;
}
#box {
transform-origin:center;
-webkit-animation-name: box;
-webkit-animation-duration: 15s;
-webkit-transform-origin:center;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-webkit-animation-direction:alternate;
animation-direction:alternate;
}
#-webkit-keyframes box {
0% { -webkit-transform: translate(0px, 20px); }
10% { -webkit-transform: translate(0px, -5px); }
20% { -webkit-transform: translate(0px, 20px); }
30% { -webkit-transform: translate(0px, -5px); }
40% { -webkit-transform: translate(0px, 20px); }
50% { -webkit-transform: translate(0px, -5px); }
60% { -webkit-transform: translate(0px, 20px); }
70% { -webkit-transform: translate(0px, -5px); }
80% { -webkit-transform: translate(0px, 20px); }
90% { -webkit-transform: translate(0px, -5px); }
100% { -webkit-transform: translate(0px, 20px); }
}
Thank you - I really appreciate it!
you should transform the div that holds the svg:
<div id='box'> <!-- transform this guy -->
<svg>
</svg>
</div>
https://jsfiddle.net/foreyez/kxb52cjz/

Safari compatible CSS3 Animation on an SVG element

I've got a strange bug I can't seem to figure out:
I want to combine two CSS animation properties (opacity & transform: translate), and my target is an inline SVG element.
The combo is perfect in Chrome, fidgety in Firefox, and doesn't work in Safari.
Safari seems only capable of doing one or the other, not both at the same time. No idea what happens in IE at the moment as I'm on a Mac.
See example: http://jsfiddle.net/712xwmss/
If anyone can help get it working smoothly across all 4 browsers it'd be greatly appreciated.
SVG:
<svg width="28" height="65" viewBox="0 0 28 65" xmlns="http://www.w3.org/2000/svg" class="center-block svgscroll">
<title>Example</title>
<g fill="none" fill-rule="evenodd">
<path d="M5 44.7l7 6.953 7-6.953" class="svgarrow sa1" stroke="red" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<path d="M3 50.66l9 8.94 9-8.94" class="svgarrow sa2" stroke="blue" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</g>
CSS:
.svgarrow {
-moz-animation: drop 1s infinite;
-webkit-animation: drop 1s infinite;
animation: drop 1s infinite;
}
.svgarrow.sa1 {
-moz-animation-delay: 0.2s;
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.svgarrow.sa2 {
-moz-animation-delay: 0.1s;
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s;
}
#-moz-keyframes drop {
0% {
-moz-transform: translateY(0px);
transform: translateY(0px);
opacity: 0;
}
100% {
-moz-transform: translateY(4px);
transform: translateY(4px);
opacity: 1;
}
}
#-webkit-keyframes drop {
0% {
-webkit-transform: translateY(0px);
transform: translateY(0px);
opacity: 0;
}
100% {
-webkit-transform: translateY(4px);
transform: translateY(4px);
opacity: 1;
}
}
#keyframes drop {
0% {
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-webkit-transform: translateY(0px);
transform: translateY(0px);
opacity: 0;
}
100% {
-moz-transform: translateY(4px);
-ms-transform: translateY(4px);
-webkit-transform: translateY(4px);
transform: translateY(4px);
opacity: 1;
}
}
You should update Safari, It is fixed on latest version.
Latest Safari version for Mac
Safari 5.1.7 (Windows)

svg file and animation for all browser

I have svg file, which i need to animate, i didn know how to animate polygon inside this file so i decide to use CSS3 animation intead, but not all browser display it right, i mean for firefox and safari there is no animation, why?
This is svg file code: (plus_animation.svg)
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="104.5px"
height="104px" viewBox="0 0 104.5 104" enable-background="new 0 0 104.5 104" xml:space="preserve">
<style type="text/css" >
<![CDATA[
#-webkit-keyframes pulse_animationW {
0% { -webkit-transform: scale(1); }
20% { -webkit-transform: scale(0.9); }
40% { -webkit-transform: scale(0.7); }
50% { -webkit-transform: scale(0.5); }
60% { -webkit-transform: scale(0.7); }
80% { -webkit-transform: scale(0.9); }
100% { -webkit-transform: scale(1); }
}
#-moz-keyframes pulse_animationM {
0% { -moz-transform: scale(1); }
20% { -moz-transform: scale(0.9); }
40% { -moz-transform: scale(0.7); }
50% { -moz-transform: scale(0.5); }
60% { -moz-transform: scale(0.7); }
80% { -moz-transform: scale(0.9); }
100% { -moz-transform: scale(1); }
}
#-moz-keyframes pulse_animationMS {
0% { -ms-transform: scale(1); }
20% { -ms-transform: scale(0.9); }
40% { -ms-transform: scale(0.7); }
50% { -ms-transform: scale(0.5); }
60% { -ms-transform: scale(0.7); }
80% { -ms-transform: scale(0.9); }
100% { -ms-transform: scale(1); }
}
#keyframes pulse_animation {
0% { transform: scale(1); }
20% { transform: scale(0.9); }
40% { transform: scale(0.7); }
50% { transform: scale(0.5); }
60% { transform: scale(0.7); }
80% { transform: scale(0.9); }
100% { transform: scale(1); }
}
#topPlus{
-webkit-animation-name: 'pulse_animationW';
-webkit-animation-duration: 1000ms;
-webkit-transform-origin:50% 50%;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-name: 'pulse_animationM';
-moz-animation-duration: 1000ms;
-moz-transform-origin:50% 50%;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
-ms-animation-name: 'pulse_animationMS';
-ms-animation-duration: 1000ms;
-ms-transform-origin:50% 50%;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
animation-name: 'pulse_animation';
animation-duration: 1000ms;
transform-origin:50% 50%;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.botPlus{
-webkit-animation-name: 'pulse_animationW';
-webkit-animation-duration: 500ms;
-webkit-transform-origin:50% 50%;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-name: 'pulse_animationM';
-moz-animation-duration: 500ms;
-moz-transform-origin:50% 50%;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
-ms-animation-name: 'pulse_animationMS';
-ms-animation-duration: 500ms;
-ms-transform-origin:50% 50%;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
animation-name: 'pulse_animation';
animation-duration: 500ms;
transform-origin:50% 50%;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
#midPlus{
-webkit-animation-name: 'pulse_animationW';
-webkit-animation-duration: 2000ms;
-webkit-transform-origin:50% 50%;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-name: 'pulse_animationM';
-moz-animation-duration:2000ms;
-moz-transform-origin:50% 50%;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
-ms-animation-name: 'pulse_animationMS';
-ms-animation-duration: 2000ms;
-ms-transform-origin:50% 50%;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
animation-name: 'pulse_animation';
animation-duration: 2000ms;
transform-origin:50% 50%;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
]]>
</style>
<g id="Warstwa_2" display="none">
<rect x="-2637.5" y="-1982" display="inline" fill="#1D1D1B" stroke="#1D1D1B" stroke-miterlimit="10" width="6919" height="3576"/>
</g>
<g id="Warstwa_1">
<g>
<polygon id="midPlus" fill="#FFFFFF" points="56,48.5 56,2.5 49,2.5 49,48.5 3,48.5 3,55.5 49,55.5 49,101.5 56,101.5 56,55.5 102,55.5
102,48.5 "/>
<rect class="botPlus" x="3.086" y="82.952" fill="#FFFFFF" width="32.817" height="3.834"/>
<rect class="botPlus" x="17.578" y="68.462" fill="#FFFFFF" width="3.834" height="32.815"/>
<polygon id="topPlus" fill="#FFFFFF" points="102,17.5 87,17.5 87,2.5 83,2.5 83,17.5 69,17.5 69,21.5 83,21.5 83,35.5 87,35.5 87,21.5
102,21.5"/>
<rect x="3.332" y="3.06" fill="none" stroke="#FFFFFF" stroke-width="0.996" stroke-miterlimit="10" width="97.971" height="97.973"/>
<rect x="3.332" y="3.06" fill="none" stroke="#FFFFFF" stroke-width="0.996" stroke-miterlimit="10" width="97.971" height="97.973"/>
<rect x="19.495" y="19.223" fill="none" stroke="#FFFFFF" stroke-width="0.996" stroke-miterlimit="10" width="65.646" height="65.646"/>
<rect x="2.833" y="2.561" fill="none" width="98.968" height="98.97"/>
</g>
</g>
</svg>
This is code in html page:
<div class="col-sm-offset-1 col-sm-2 text-center logoSVG">
<img src="~/Content/img/technology_partners/benefits/plus.svg" alt="SVG">
<p class="benefit-description">#Model.Benefit_1Text</p>
</div>
this is jQuery code:
$(document).ready(function () {
$('#benefits-div .logoSVG img').hover(function () {
var split = $(this).attr("src").split(".svg");
$(this).attr("src", split[0] + "_animation.svg");
}, function () {
var split = $(this).attr("src").split("_animation.svg");
$(this).attr("src", split[0] + ".svg");
});
});

css3 keyframe animation for path in svg symbol tag

Is it possible to animate a path in the symbol tag with css3 keyframe animation? It doesn't work in my case.
Example:
http://codepen.io/anon/pen/Hfbmr
HTML:
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="icon-love" viewBox="0 0 54 54">
<title>Love</title>
<path id="icon-love-circle" fill="#000000" d="M27,3c13.2,0,24,10.8,24,24S40.2,51,27,51S3,40.2,3,27S13.8,3,27,3 M27,0C12.1,0,0,12.1,0,27
s12.1,27,27,27s27-12.1,27-27S41.9,0,27,0L27,0z"/>
<path id="icon-love-heart" fill="#000000" d="M15.2,23.2c0-2,0.6-3.5,1.7-4.6c1.1-1.1,2.7-1.7,4.7-1.7c0.6,0,1.1,0.1,1.7,0.3c0.6,0.2,1.1,0.5,1.6,0.8
c0.5,0.3,0.9,0.6,1.3,0.9c0.4,0.3,0.7,0.6,1,0.9c0.3-0.3,0.7-0.6,1-0.9c0.4-0.3,0.8-0.6,1.3-0.9c0.5-0.3,1-0.6,1.6-0.8
c0.6-0.2,1.1-0.3,1.7-0.3c2,0,3.6,0.6,4.7,1.7c1.1,1.1,1.7,2.6,1.7,4.6c0,2-1,4-3.1,6l-8.3,8c-0.2,0.2-0.4,0.2-0.6,0.2
c-0.2,0-0.4-0.1-0.6-0.2l-8.4-8.1c-0.1-0.1-0.2-0.2-0.4-0.3c-0.2-0.2-0.4-0.5-0.7-0.9c-0.3-0.4-0.6-0.9-0.9-1.3
c-0.3-0.4-0.5-1-0.7-1.6C15.4,24.4,15.2,23.8,15.2,23.2z M17,23.2c0,1.5,0.8,3.1,2.5,4.8l7.8,7.5L35,28c1.7-1.7,2.5-3.3,2.5-4.8
c0-0.7-0.1-1.4-0.3-1.9c-0.2-0.6-0.4-1-0.7-1.3c-0.3-0.3-0.7-0.6-1.1-0.8c-0.4-0.2-0.8-0.3-1.3-0.4c-0.4-0.1-0.8-0.1-1.3-0.1
s-1,0.1-1.5,0.3c-0.5,0.2-1,0.5-1.5,0.9c-0.5,0.3-0.8,0.7-1.2,1c-0.3,0.3-0.6,0.6-0.8,0.8c-0.2,0.2-0.4,0.3-0.7,0.3
s-0.5-0.1-0.7-0.3c-0.2-0.2-0.5-0.5-0.8-0.8c-0.3-0.3-0.7-0.6-1.2-1c-0.5-0.3-0.9-0.6-1.5-0.9c-0.5-0.2-1-0.3-1.5-0.3
c-0.5,0-0.9,0-1.3,0.1c-0.4,0.1-0.8,0.2-1.3,0.4c-0.4,0.2-0.8,0.5-1.1,0.8c-0.3,0.3-0.5,0.8-0.7,1.3C17.1,21.8,17,22.5,17,23.2z"
/>
</symbol>
CSS:
.icon-love {
height: 54px;
width: 54px;
}
#icon-love-heart {
animation-name: 'heartbeat';
animation-duration: 5000ms;
transform-origin:70% 70%;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
#keyframes heartbeat {
0% { transform: scale(1); }
30% { transform: scale(1); }
40% { transform: scale(1.08); }
50% { transform: scale(1); }
60% { transform: scale(1); }
70% { transform: scale(1.05); }
80% { transform: scale(1); }
100% { transform: scale(1); }
}
Cheers Philip
It is perfectly possible. It works if you drop <use xlink:href="#icon-love"/> part and just use normal svg. If you are concenrned about maintaining your code clean I suggest you store your svg in a variable and output it dynamically instead of using the <use> tag, which breaks the animation.
http://codepen.io/easwee/pen/xFDbu
<svg class="icon-love" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 54">
<path id="icon-love-circle" fill="#000000" d="M27,3c13.2,0,24,10.8,24,24S40.2,51,27,51S3,40.2,3,27S13.8,3,27,3 M27,0C12.1,0,0,12.1,0,27
s12.1,27,27,27s27-12.1,27-27S41.9,0,27,0L27,0z"/>
<path class="icon-love-heart" fill="#000000" d="M15.2,23.2c0-2,0.6-3.5,1.7-4.6c1.1-1.1,2.7-1.7,4.7-1.7c0.6,0,1.1,0.1,1.7,0.3c0.6,0.2,1.1,0.5,1.6,0.8
c0.5,0.3,0.9,0.6,1.3,0.9c0.4,0.3,0.7,0.6,1,0.9c0.3-0.3,0.7-0.6,1-0.9c0.4-0.3,0.8-0.6,1.3-0.9c0.5-0.3,1-0.6,1.6-0.8
c0.6-0.2,1.1-0.3,1.7-0.3c2,0,3.6,0.6,4.7,1.7c1.1,1.1,1.7,2.6,1.7,4.6c0,2-1,4-3.1,6l-8.3,8c-0.2,0.2-0.4,0.2-0.6,0.2
c-0.2,0-0.4-0.1-0.6-0.2l-8.4-8.1c-0.1-0.1-0.2-0.2-0.4-0.3c-0.2-0.2-0.4-0.5-0.7-0.9c-0.3-0.4-0.6-0.9-0.9-1.3
c-0.3-0.4-0.5-1-0.7-1.6C15.4,24.4,15.2,23.8,15.2,23.2z M17,23.2c0,1.5,0.8,3.1,2.5,4.8l7.8,7.5L35,28c1.7-1.7,2.5-3.3,2.5-4.8
c0-0.7-0.1-1.4-0.3-1.9c-0.2-0.6-0.4-1-0.7-1.3c-0.3-0.3-0.7-0.6-1.1-0.8c-0.4-0.2-0.8-0.3-1.3-0.4c-0.4-0.1-0.8-0.1-1.3-0.1
s-1,0.1-1.5,0.3c-0.5,0.2-1,0.5-1.5,0.9c-0.5,0.3-0.8,0.7-1.2,1c-0.3,0.3-0.6,0.6-0.8,0.8c-0.2,0.2-0.4,0.3-0.7,0.3
s-0.5-0.1-0.7-0.3c-0.2-0.2-0.5-0.5-0.8-0.8c-0.3-0.3-0.7-0.6-1.2-1c-0.5-0.3-0.9-0.6-1.5-0.9c-0.5-0.2-1-0.3-1.5-0.3
c-0.5,0-0.9,0-1.3,0.1c-0.4,0.1-0.8,0.2-1.3,0.4c-0.4,0.2-0.8,0.5-1.1,0.8c-0.3,0.3-0.5,0.8-0.7,1.3C17.1,21.8,17,22.5,17,23.2z"
/>
</svg>
Also added prefixes for crossbrowser css (webkit, firefox and standard):
.icon-love {width:54px;height:54px;}
.icon-love-heart {
-moz-animation: heartbeat 5s linear infinite;
-webkit-animation: heartbeat 5s linear infinite;
animation: heartbeat 5s linear infinite;
-moz-transform-origin:50% 50%;
-webkit-transform-origin:50% 50%;
transform-origin:50% 50%;
}
#-moz-keyframes heartbeat {
0% { -moz-transform: scale(1); }
30% { -moz-transform: scale(1); }
40% { -moz-transform: scale(1.08); }
50% { -moz-transform: scale(1); }
60% { -moz-transform: scale(1); }
70% { -moz-transform: scale(1.05); }
80% { -moz-transform: scale(1); }
100% { -moz-transform: scale(1); }
}
#-webkit-keyframes heartbeat {
0% { -webkit-transform: scale(1); }
30% { -webkit-transform: scale(1); }
40% { -webkit-transform: scale(1.08); }
50% { -webkit-transform: scale(1); }
60% { -webkit-transform: scale(1); }
70% { -webkit-transform: scale(1.05); }
80% { -webkit-transform: scale(1); }
100% { -webkit-transform: scale(1); }
}
#keyframes heartbeat {
0% { transform: scale(1); }
30% { transform: scale(1); }
40% { transform: scale(1.08); }
50% { transform: scale(1); }
60% { transform: scale(1); }
70% { transform: scale(1.05); }
80% { transform: scale(1); }
100% { transform: scale(1); }
}

Resources