Ok, so I have this HTML code for an I Love You animation. And I'm having some difficult time to adjust it as an inline code.
Is this possible in any way?
.heart {
fill: red;
position: relative;
top: 5px;
width: 50px;
animation: pulse 1s ease infinite;
}
#keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.3); }
100% { transform: scale(1); }
}
I
<svg class="heart" viewBox="0 0 32 29.6">
<path d="M23.6,0c-3.4,0-6.3,2.7-7.6,5.6C14.7,2.7,11.8,0,8.4,0C3.8,0,0,3.8,0,8.4c0,9.4,9.5,11.9,16,21.2
c6.1-9.3,16-12.1,16-21.2C32,3.8,28.2,0,23.6,0z"/>
</svg>
You
You can try like below with pure SVG and no external CSS (only inline)
I
<svg class="heart" viewBox="0 0 32 29.6" width="50" style="overflow:visible;position: relative;top: 5px;">
<g transform-origin="center">
<path d="M23.6,0c-3.4,0-6.3,2.7-7.6,5.6C14.7,2.7,11.8,0,8.4,0C3.8,0,0,3.8,0,8.4c0,9.4,9.5,11.9,16,21.2
c6.1-9.3,16-12.1,16-21.2C32,3.8,28.2,0,23.6,0z" fill="red"/>
<animateTransform attributeName="transform"
type="scale"
keyTimes="0;0.5;1" values="1;1.3;1"
dur="1s" repeatCount="indefinite"/>
</g>
</svg>
You
You might include the style into svg element itself:
I
<svg class="heart" viewBox="0 0 32 29.6">
<style>
.heart {
fill: red;
position: relative;
top: 5px;
width: 50px;
animation: pulse 1s ease infinite
}
#keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.3); }
100% { transform: scale(1); }
}
</style>
<path d="M23.6,0c-3.4,0-6.3,2.7-7.6,5.6C14.7,2.7,11.8,0,8.4,0C3.8,0,0,3.8,0,8.4c0,9.4,9.5,11.9,16,21.2
c6.1-9.3,16-12.1,16-21.2C32,3.8,28.2,0,23.6,0z"/>
</svg>
You
You can place the keyframe and css inside the styles tag inside svg. Like here
<svg">
<style type="text/css">
.heart {
fill: red;
position: relative;
top: 5px;
width: 50px;
animation: pulse 1s ease infinite,
}
#keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.3); }
100% { transform: scale(1); }
}
</style>
</svg>
https://codepen.io/shshaw/pen/WvYJQP.
But the inline can not be done.
You can use scoped style. It will only affect his direct parent and content.
I
<svg class="heart" viewBox="0 0 32 29.6">
<style scoped>
.heart {
fill: red;
position: relative;
top: 5px;
width: 50px;
animation: pulse 1s ease infinite;
}
#keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.3); }
100% { transform: scale(1); }
}
</style>
<path d="M23.6,0c-3.4,0-6.3,2.7-7.6,5.6C14.7,2.7,11.8,0,8.4,0C3.8,0,0,3.8,0,8.4c0,9.4,9.5,11.9,16,21.2
c6.1-9.3,16-12.1,16-21.2C32,3.8,28.2,0,23.6,0z"/>
</svg>
You
Related
Issue
I am trying to use a font awesome icon fas fa-cannabis and add a fill effect, now I have part of the CSS down, I can see the loading animation but I can't get it to fill inside the font awesome icon. So all I basically want to do is put that fill effect that you can see below inside of the font awesome icon.
Here is the CodePen for the question
At the moment it is sitting underneath the font awesome icon. Which you can see below:
Code
So my HTML is as follows:
<i class="fas fa-cannabis" id="banner">
<div class="fill">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="300px" height="300px" viewBox="0 0 300 300" enable-background="new 0 0 300 300" xml:space="preserve">
<path fill="#04ACFF" id="waveShape" d="M300,300V2.5c0,0-0.6-0.1-1.1-0.1c0,0-25.5-2.3-40.5-2.4c-15,0-40.6,2.4-40.6,2.4
c-12.3,1.1-30.3,1.8-31.9,1.9c-2-0.1-19.7-0.8-32-1.9c0,0-25.8-2.3-40.8-2.4c-15,0-40.8,2.4-40.8,2.4c-12.3,1.1-30.4,1.8-32,1.9
c-2-0.1-20-0.8-32.2-1.9c0,0-3.1-0.3-8.1-0.7V300H300z"/>
</svg>
</div>
</i>
With the following CSS that is creating the fill effect:
#banner {
width: 150px;
height: 150px;
overflow: hidden;
backface-visibility: hidden;
transform: translate3d(0, 0, 0);
}
#banner .fill {
animation-name: fillAction;
animation-iteration-count: 1;
animation-timing-function: cubic-bezier(.2, .6, .8, .4);
animation-duration: 4s;
animation-fill-mode: forwards;
}
#banner #waveShape {
animation-name: waveAction;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-duration: 0.5s;
width:300px;
height: 150px;
fill: #04ACFF;
}
#keyframes fillAction {
0% {
transform: translate(0, 150px);
}
100% {
transform: translate(0, -5px);
}
}
#keyframes waveAction {
0% {
transform: translate(-150px, 0);
}
100% {
transform: translate(0, 0);
}
}
You can use mix-blend-mode:screen; For this I'm wrapping both the i and the fill in a div and set i{position:absolute}. Please take a look at the codepen demo
#wrap{height: 150px;
width:150px;
overflow: hidden;
border:1px solid;
}
#banner {
height: 150px;
width:150px;
}
.fill {
animation-name: fillAction;
animation-iteration-count: 1;
animation-timing-function: cubic-bezier(.2, .6, .8, .4);
animation-duration: 4s;
animation-fill-mode: forwards;
mix-blend-mode:screen;
}
#waveShape {
animation-name: waveAction;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-duration: 0.5s;
width:300px;
height: 150px;
fill: #04ACFF;
}
#keyframes fillAction {
0% {
transform: translate(0, 150px);
}
100% {
transform: translate(0, -5px);
}
}
#keyframes waveAction {
0% {
transform: translate(-150px, 0);
}
100% {
transform: translate(0, 0);
}
}
i{font-size:147px; background:#fff;}
#wrap i{position:absolute}
<div id="wrap">
<i class="fas fa-cannabis" id="banner"></i>
<div class="fill">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="300px" viewBox="0 0 300 300" enable-background="new 0 0 300 300" xml:space="preserve">
<path fill="#04ACFF" id="waveShape" d="M300,300V2.5c0,0-0.6-0.1-1.1-0.1c0,0-25.5-2.3-40.5-2.4c-15,0-40.6,2.4-40.6,2.4
c-12.3,1.1-30.3,1.8-31.9,1.9c-2-0.1-19.7-0.8-32-1.9c0,0-25.8-2.3-40.8-2.4c-15,0-40.8,2.4-40.8,2.4c-12.3,1.1-30.4,1.8-32,1.9
c-2-0.1-20-0.8-32.2-1.9c0,0-3.1-0.3-8.1-0.7V300H300z"/>
</svg>
</div>
</div>
You might need to use clipping paths to apply the fill only to the icon. You might also need to use an svg rather than an icon...
This article has some interesting info that may help: https://css-tricks.com/masking-vs-clipping-use/
#home {
height: 100vh;
background-image: url("http://4.bp.blogspot.com/-yB6Tc3mleuE/T4NkAKeazYI/AAAAAAAACB0/tlichKzIu3Q/s1600/Simple+unique+odd+weird+wallpapers+minimalistic+%2330+battleship+titanic.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
padding: 0;
margin-left: -10px;
}
.background {
overflow: hidden;
}
#fg {
fill: pink;
stroke: #fff;
stroke-width: 10px;
stroke-dasharray: 1024px;
-webkit-animation: dash 2s;
animation: dash 2s;
}
#keyframes dash {
from {
stroke-dashoffset: 1024px;
}
to {
stroke-dashoffset: 0px;
}
}
#-webkit-keyframes dash {
from {
stroke-dashoffset: 1024px;
}
to {
stroke-dashoffset: 0px;
}
}
#bg {
fill: white;
stroke: none;
transform-origin: 1270px 550px;
-webkit-animation: bgfill 2s linear 2s forwards;
animation: bgfill 2s linear 2s forwards;
}
#keyframes bgfill {
from {
transform: scale(1);
}
to {
transform: scale(4);
}
}
#-webkit-keyframes bgfill {
from {
transform: scale(1);
}
to {
transform: scale(4);
}
}
<div id="home" class="section" style="height:100vh;">
<div class="background">
<svg viewBox="0 0 1376 764">
<defs>
<path id="shape" d="M1034.5,770.5a125.59,125.59,0,0,0-17-32c-12.32-16.72-25.68-25.84-33-31-6-4.23-59.88-42.55-100-90-13.64-16.14-20.57-24.48-26-38-15-37.48-3.73-73.65,0-85,8.68-26.45,23-43.26,35-57,19-21.82,33.56-29.9,67-54,33.68-24.27,55.39-39.91,77-60,40.56-37.69,35.94-49.35,81-96,34.18-35.39,51.27-53.08,79-65,7.79-3.35,76-31.44,140,2a142.06,142.06,0,0,1,31,22l7.5,7.5 L 1376,770.5 Z" />
</defs>
<use xlink:href="#shape" id="bg" />
<use xlink:href="#shape" id="fg" />
</svg>
</div>
</div>
I can not seem to make the background image visible at all times while remaining the same effect, making the fill transparent gets rid of the animation, I also tried to play around with z-index on various elements but without success, how can I make it so that the background image is visible inside the white line instead of the pink svg?
I also tried applying the same image to the pink SVG as fill and it kind of works, I just can not seem to make the image appear like how it would if it was full screen, it also makes the page a bit slow:
#fg {
fill: url(#image);
stroke: #fff;
stroke-width: 10px;
stroke-dasharray: 1024px;
-webkit-animation: dash 2s;
animation: dash 2s;
}
<pattern id="image" width="1" height="1">
<image xlink:href="http://4.bp.blogspot.com/-yB6Tc3mleuE/T4NkAKeazYI/AAAAAAAACB0/tlichKzIu3Q/s1600/Simple+unique+odd+weird+wallpapers+minimalistic+%2330+battleship+titanic.jpg"></image>
</pattern>
You can get rid of the pink with fill-opacity. But you would need to adjust the white "background" as it overlays the background-image.
You might need to change the shape for that.
You could also include the image as a layer in the svg.
#home {
height: 100vh;
background-image: url("http://4.bp.blogspot.com/-yB6Tc3mleuE/T4NkAKeazYI/AAAAAAAACB0/tlichKzIu3Q/s1600/Simple+unique+odd+weird+wallpapers+minimalistic+%2330+battleship+titanic.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
padding: 0;
margin-left: -10px;
}
.background {
overflow: hidden;
}
#fg {
fill: pink;
fill-opacity: 0;
stroke: #fff;
stroke-width: 10px;
stroke-dasharray: 1024px;
-webkit-animation: dash 2s;
animation: dash 2s;
}
#keyframes dash {
from {
stroke-dashoffset: 1024px;
}
to {
stroke-dashoffset: 0px;
}
}
#-webkit-keyframes dash {
from {
stroke-dashoffset: 1024px;
}
to {
stroke-dashoffset: 0px;
}
}
#bg {
fill: white;
opacity: .5;
stroke: none;
transform-origin: 1270px 550px;
-webkit-animation: bgfill 2s linear 2s forwards;
animation: bgfill 2s linear 2s forwards;
}
#keyframes bgfill {
from {
transform: scale(1);
}
to {
transform: scale(4);
}
}
#-webkit-keyframes bgfill {
from {
transform: scale(1);
}
to {
transform: scale(4);
}
}
<div id="home" class="section" style="height:100vh;">
<div class="background">
<svg viewBox="0 0 1376 764">
<defs>
<path id="shape" d="M1034.5,770.5a125.59,125.59,0,0,0-17-32c-12.32-16.72-25.68-25.84-33-31-6-4.23-59.88-42.55-100-90-13.64-16.14-20.57-24.48-26-38-15-37.48-3.73-73.65,0-85,8.68-26.45,23-43.26,35-57,19-21.82,33.56-29.9,67-54,33.68-24.27,55.39-39.91,77-60,40.56-37.69,35.94-49.35,81-96,34.18-35.39,51.27-53.08,79-65,7.79-3.35,76-31.44,140,2a142.06,142.06,0,0,1,31,22l7.5,7.5 L 1376,770.5 Z" />
</defs>
<use xlink:href="#shape" id="bg" />
<use xlink:href="#shape" id="fg" />
</svg>
</div>
</div>
SVG width attribute css animation not working in Firefox but in chrome it working perfectly. Please check the below snippet demo.
Does any wrong in my codes? Is there a way to apply the animation over the attribute width?
svg {
display: inline-block;
}
#-moz-keyframes glareAnim1 {
0% {
width: 0;
}
50% {
width: 10px;
}
100% {
width: 0;
}
}
#-webkit-keyframes glareAnim1 {
0% {
width: 0;
}
50% {
width: 10px;
}
100% {
width: 0;
}
}
#keyframes glareAnim1 {
0% {
width: 0;
}
50% {
width: 10px;
}
100% {
width: 0;
}
}
.glare-top {
-moz-animation: glareAnim1 2s linear infinite;
-webkit-animation: glareAnim1 2s linear infinite;
animation: glareAnim1 2s linear infinite;
}
#-moz-keyframes glareAnim2 {
0% {
width: 10px;
}
50% {
width: 0;
}
100% {
width: 10px;
}
}
#-webkit-keyframes glareAnim2 {
0% {
width: 10px;
}
50% {
width: 0;
}
100% {
width: 10px;
}
}
#keyframes glareAnim2 {
0% {
width: 10px;
}
50% {
width: 0;
}
100% {
width: 10px;
}
}
.glare-bottom {
-moz-animation: glareAnim2 2s linear infinite;
-webkit-animation: glareAnim2 2s linear infinite;
animation: glareAnim2 2s linear infinite;
}
#-moz-keyframes translateDoor {
0% {
-moz-transform: translate(-1px, 0);
transform: translate(-1px, 0);
opacity: 1;
width: 1px;
height: 6px;
}
15% {
width: 4px;
}
50% {
-moz-transform: translate(16px, 0);
transform: translate(16px, 0);
opacity: 1;
width: 2px;
}
51% {
opacity: 0;
}
100% {
-moz-transform: translateX(-10px);
transform: translateX(-10px);
opacity: 0;
}
}
#-webkit-keyframes translateDoor {
0% {
-webkit-transform: translate(-1px, 0);
transform: translate(-1px, 0);
opacity: 1;
width: 1px;
height: 6px;
}
15% {
width: 4px;
}
50% {
-webkit-transform: translate(16px, 0);
transform: translate(16px, 0);
opacity: 1;
width: 2px;
}
51% {
opacity: 0;
}
100% {
-webkit-transform: translateX(-10px);
transform: translateX(-10px);
opacity: 0;
}
}
#keyframes translateDoor {
0% {
-moz-transform: translate(-1px, 0);
-ms-transform: translate(-1px, 0);
-webkit-transform: translate(-1px, 0);
transform: translate(-1px, 0);
opacity: 1;
width: 1px;
height: 6px;
}
15% {
width: 4px;
}
50% {
-moz-transform: translate(16px, 0);
-ms-transform: translate(16px, 0);
-webkit-transform: translate(16px, 0);
transform: translate(16px, 0);
opacity: 1;
width: 2px;
}
51% {
opacity: 0;
}
100% {
-moz-transform: translateX(-10px);
-ms-transform: translateX(-10px);
-webkit-transform: translateX(-10px);
transform: translateX(-10px);
opacity: 0;
}
}
.researchDoor {
fill: #464949;
-moz-animation: translateDoor 5s linear infinite;
-webkit-animation: translateDoor 5s linear infinite;
animation: translateDoor 5s linear infinite;
}
.research0 {
fill: #FFFFFF;
stroke: #464949;
stroke-width: 2;
stroke-miterlimit: 10;
}
.research1 {
fill: #FCBD38;
overflow: hidden;
}
.research2 {
fill: #464949;
}
.research3 {
fill: none;
stroke: #464949;
stroke-width: 2;
stroke-linecap: square;
stroke-miterlimit: 10;
}
<svg version="1.1" x="0px" y="0px" viewBox="0 0 100 120" style="enable-background:new 0 0 100 120;" xml:space="preserve">
<path id="XMLID_42_" class="research0" d="M57.9,25.5c-3-6.4-8.3-11.6-8.3-11.6c-5.1,5-8.3,11.5-8.3,11.5v5.8L57.7,32L57.9,25.5z" />
<g id="XMLID_40_">
<rect x="41.4" y="25.9" class="research1" width="16.3" height="11.5" />
<path class="research2" d="M56.7,26.9v9.5H42.4v-9.5H56.7 M58.7,24.9H40.4v13.5h18.3V24.9L58.7,24.9z" />
</g>
<polygon id="XMLID_43_" class="research3" points="33.5,85.2 40.8,37.7 58.8,37.7 66.2,85.2 " />
<!-- door -->
<rect x="41" y="28.9" class="researchDoor" />
<!-- left top wind -->
<rect x="30" class="glare-top" y="28" fill="#464949" width="14" height="2" />
<!-- left bottom wind -->
<rect x="30" class="glare-bottom" y="32" fill="#464949" width="14" height="2" />
<!-- right top wind -->
<rect x="62" y="28" class="glare-top" fill="#464949" width="14" height="2" />
<!-- right bottom wind -->
<rect x="62" y="32" class="glare-bottom" fill="#464949" width="14" height="2" />
<!--
<line id="glareLeftTop" class="research3" x1="36.6" y1="28.7" x2="32.8" y2="28.7"/>
<line id="glareLeftBottom" class="research3" x1="36.6" y1="33.3" x2="23.8" y2="33.3"/>
<line id="glareTopRight" class="research3" x1="62.9" y1="28.7" x2="66.6" y2="28.7"/>
<line id="glareTopBottom" class="research3" x1="62.9" y1="33.3" x2="75.6" y2="33.3"/>
-->
<line id="XMLID_2_" class="research3" x1="76.3" y1="85.3" x2="23.7" y2="85.3" />
<line id="XMLID_64_" class="research3" x1="60.7" y1="37.7" x2="38.8" y2="37.7" />
<line id="XMLID_70_" class="research3" x1="58.7" y1="44.3" x2="40.8" y2="44.3" />
<line id="XMLID_79_" class="research3" x1="60.2" y1="51.7" x2="39.3" y2="51.7" />
<line id="XMLID_80_" class="research3" x1="61.7" y1="61" x2="37.8" y2="61" />
<line id="XMLID_90_" class="research3" x1="63.5" y1="69.3" x2="36.8" y2="69.3" />
<g id="XMLID_49_">
<path class="research2" d="M49.8,76.2c1.5,0,2.8,1.2,2.8,2.8v5.2H47v-5.2C47,77.4,48.2,76.2,49.8,76.2 M49.8,74.2
c-2.6,0-4.8,2.1-4.8,4.8v7.2h9.5v-7.2C54.5,76.3,52.4,74.2,49.8,74.2L49.8,74.2z" />
</g>
</svg>
Consider using lines with a stroke-width equal to the height of the rectangles instead of rectangles in your animation.
The stroke-dasharray lines will be used for animation.
At 0% {stroke-dasharray: 0.10;} for an animated line equal to 10px
the line will be hidden
At 50% {stroke-dasharray: 10,0;} the line will be shown in full
At 100% {stroke-dasharray: 0.10;} the line will be hidden again
.glare-top {
-webkit-animation: glareAnim1 2s linear infinite;
stroke-dasharray:0,10;
animation: glareAnim1 2s linear infinite;
}
#-webkit-keyframes glareAnim1 {
0% {stroke-dasharray:0,10;}
50% {stroke-dasharray:10,10;}
100%{stroke-dasharray:0,10;}
}
.glare-bottom {
-webkit-animation: glareAnim2 2s linear infinite;
stroke-dasharray:0,10;
animation: glareAnim2 2s linear infinite;
}
#-webkit-keyframes glareAnim2 {
0% {stroke-dasharray:10,0;}
50% {stroke-dasharray:0,10;}
100%{stroke-dasharray:10,0;}
}
<svg version="1.1" viewBox="0 0 100 120" >
<!-- left top wind -->
<polyline class="glare-top" points="27,28 37,28" stroke="#464949" stroke-width="2" />
<!-- left bottom wind -->
<polyline class="glare-bottom" points="27,33 37,33" stroke="#464949" stroke-width="2" />
</svg>
I have shortened your code to show the basic animation of the lines and the door.
svg {
display: inline-block;
}
.glare-top {
-webkit-animation: glareAnim1 2s linear infinite;
stroke-dasharray:0,10;
animation: glareAnim1 2s linear infinite;
}
#-webkit-keyframes glareAnim1 {
0% {stroke-dasharray:0,10;}
50% {stroke-dasharray:10,10;}
100%{stroke-dasharray:0,10;}
}
#keyframes glareAnim1 {
0% {stroke-dasharray:0,10;}
50% {stroke-dasharray:10,10;}
100%{stroke-dasharray:0,10;}
}
.glare-bottom {
-moz-animation: glareAnim2 2s linear infinite;
-webkit-animation: glareAnim2 2s linear infinite;
stroke-dasharray:0,10;
animation: glareAnim2 2s linear infinite;
}
#-webkit-keyframes glareAnim2 {
0% {stroke-dasharray:10,0;}
50% {stroke-dasharray:0,10;}
100%{stroke-dasharray:10,0;}
}
#keyframes glareAnim2 {
0% {stroke-dasharray:10,0;}
50% {stroke-dasharray:0,10;}
100%{stroke-dasharray:10,0;}
}
.researchDoor {
fill: #464949;
stroke-dasharray:0,6;
animation: translateDoor 5s linear infinite;
}
#keyframes translateDoor {
0% {
transform: translate(-1px, 0);
opacity: 1;
stroke-dasharray:0,6;
}
15% {
stroke-dasharray:1.4,4.6;
}
50% {
transform: translate(8px, 0);
stroke-dasharray:5,1;
}
70% {
transform: translate(12.8px, 0);
stroke-dasharray:3.5,2.5;
}
100% {
transform: translateX(16px);
stroke-dasharray:0,6;
}
}
.research0 {
fill: #FFFFFF;
stroke: #464949;
stroke-width: 2;
stroke-miterlimit: 10;
}
.research1 {
fill: #FCBD38;
overflow: hidden;
}
.research2 {
fill: #464949;
}
.research3 {
fill: none;
stroke: #464949;
stroke-width: 2;
stroke-linecap: square;
stroke-miterlimit: 10;
}
<svg version="1.1" viewBox="0 0 100 120" >
<path id="XMLID_42_" class="research0" d="M57.9,25.5c-3-6.4-8.3-11.6-8.3-11.6c-5.1,5-8.3,11.5-8.3,11.5v5.8L57.7,32L57.9,25.5z" />
<g id="XMLID_40_">
<rect x="41.4" y="25.9" class="research1" width="16.3" height="11.5" />
<path class="research2" d="M56.7,26.9v9.5H42.4v-9.5H56.7 M58.7,24.9H40.4v13.5h18.3V24.9L58.7,24.9z" />
</g>
<polygon id="XMLID_43_" class="research3" points="33.5,85.2 40.8,37.7 58.8,37.7 66.2,85.2 " />
<!-- door -->
<!-- <rect x="41" y="28.9" class="researchDoor" /> -->
<polyline class="researchDoor" points="41,32 47,32" stroke="#464949" stroke-width="6" />
<!-- left top wind -->
<polyline class="glare-top" points="27,28 37,28" stroke="#464949" stroke-width="2" />
<!-- right top wind -->
<polyline class="glare-top" points=" 62,28 72,28" stroke="#464949" stroke-width="2" />
<!-- left bottom wind -->
<polyline class="glare-bottom" points="27,33 37,33" stroke="#464949" stroke-width="2" />
<!-- right bottom wind -->
<polyline class="glare-bottom" points=" 62,33 72,33" stroke="#464949" stroke-width="2" />
<line id="XMLID_2_" class="research3" x1="76.3" y1="85.3" x2="23.7" y2="85.3" />
<line id="XMLID_64_" class="research3" x1="60.7" y1="37.7" x2="38.8" y2="37.7" />
<line id="XMLID_70_" class="research3" x1="58.7" y1="44.3" x2="40.8" y2="44.3" />
<line id="XMLID_79_" class="research3" x1="60.2" y1="51.7" x2="39.3" y2="51.7" />
<line id="XMLID_80_" class="research3" x1="61.7" y1="61" x2="37.8" y2="61" />
<line id="XMLID_90_" class="research3" x1="63.5" y1="69.3" x2="36.8" y2="69.3" />
<g id="XMLID_49_">
<path class="research2" d="M49.8,76.2c1.5,0,2.8,1.2,2.8,2.8v5.2H47v-5.2C47,77.4,48.2,76.2,49.8,76.2 M49.8,74.2
c-2.6,0-4.8,2.1-4.8,4.8v7.2h9.5v-7.2C54.5,76.3,52.4,74.2,49.8,74.2L49.8,74.2z" />
</g>
</svg>
In SVG 1.1 width is an attribute and cannot be animated with CSS animation.
In the SVG 2 specification width is a CSS property which can therefore be animated with CSS animation.
Chrome has implemented this part of the SVG 2 specification, Firefox had not when this question was first written, but it has now. In fact Firefox has had this functionality for quite a while now.
I have an SVG with #keyframe animationS defined inside a <style> block within the file, which I embed in a page using the background-image property.
The animation works perfectly in Chrome and Safari, but not in Firefox. When the image itself is viewed in Firefox, the animation works as expected.
.loader {
height: 3.375rem;
width: 3.375rem;
background: url("http://www.haaretz.co.il/htz/images/htz-spinner.svg");
}
<div class="loader"></div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160">
<style>
.alef {
fill: #fff
}
.alef-bg {
fill: #09A5D9
}
.commet-wrapper {
-ms-transform: translate(76px, 76px) scale(-1, .57) skewY(50deg);
-webkit-transform: translate(76px, 76px) scale(-1, .57) skewY(50deg);
transform: translate(76px, 76px) scale(-1, .57) skewY(50deg);
}
.commet {
fill: #067194;
-webkit-animation: color-change 2s linear infinite .8s, spin 1s linear infinite;
animation: color-change 2s linear infinite .8s, spin 1s linear infinite;
}
#-webkit-keyframes color-change {
0%, 100% {
fill: #067194;
}
50% {
fill: #79C9E4;
}
}
#-webkit-keyframes spin {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0deg);
}
}
#keyframes color-change {
0%, 100% {
fill: #067194;
}
50% {
fill: #79C9E4;
}
}
#keyframes spin {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0deg);
}
}
</style>
<g id="lower">
<circle class="alef-bg" cx="80" cy="80" r="50" />
<path class="alef" d="M100.281,68.29l2.867-1.655c0.439,1.038,0.813,1.661,0.813,1.661S102.515,68.293,100.281,68.29z M72.541,93.58c0,0-4.308-0.04-8.036,0c-1.929,0.022-3.277-0.844-4.204-2.207l-4.653,2.686c-0.612,5.78-1.794,10.405-2.4,12.212 c-0.464,0.86,0.084,0.932,0.084,0.932h21.388C70.909,99.456,72.541,93.58,72.541,93.58z M104.421,87.988 c-5.284-3.548-9.372-6.944-16.08-11.5c-0.273-0.185-0.525-0.496-0.742-0.875l-12.45,7.188l31.58,23.203 c-0.072-0.144,0.264-0.152,0.2-0.292c-1.436-2.984-2.436-6-2.944-9.076C103.341,92.728,103.593,91.712,104.421,87.988z"
/>
</g>
<g class="commet-wrapper">
<path class="commet" d="M0,70c35.899,0,48-31.34,48-70c0-19,27-19,27,0C75,38.66,41.421,70,0,70z">
</path>
</g>
<g id="upper">
<path class="alef-bg" d="M123.3,55C109.493,31.086,78.914,22.893,55,36.7S22.893,81.086,36.7,105L123.3,55z" />
<path class="alef" d="M55.785,65.404c-0.544,5.612-1.276,6.4-1.268,11.048c0.004,5.068,1.708,9.352,1.404,14.356 c-0.066,1.117-0.161,2.201-0.272,3.251l2.933-0.382l1.72-2.305c-1.925-2.832-2.004-7.837-1.52-11.661 c0.548-4.304,3.132-6.432,3.328-6.492l13.04,9.581l7.962-2.317l4.488-4.871c-0.509-0.887-0.812-2.186-0.622-3.397 c0.352-2.192,2.24-3.932,4.084-3.932c3.468,0,6.805,0.003,9.22,0.006l2.518-0.469l0.35-1.186c-1.148-2.713-2.76-8.355,0.561-13.831 c-16.072,0-18.04-0.008-18.04-0.008c0,1.228-0.672,2.784-0.528,5.372c0.148,2.664,1.812,4.844,0.756,8.856 c-0.828,3.144-1.864,4.552-2.776,5.152c-8.428-6.264-20.696-15.256-25.836-19.34l-3.508-0.004c0,0-0.312-0.048-0.208,0.164 C55.397,56.592,56.177,61.328,55.785,65.404z"
/>
</g>
</svg>
Any help would be appreciated, thanks in advance.
This is a bug within Firefox
See bugs:
bugzilla.mozilla.org/show_bug.cgi?id=908634
and
bugzilla.mozilla.org/show_bug.cgi?id=1121478
Only embedded SVG works.
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);
}
}