Resizing svg element - html

I need a flexible svg element, but this is the first time using it.
I tried to change the width, heigh & even set positioning property for the circle but none of them work. How to resize this circle?
Thanks in advance
.chart {
position: relative;
display: inline-block;
color: #999;
font-size: 20px;
text-align: center;
}
.chart figcaption {
position: absolute;
top: 38%;
left: 39%;
}
.outer {
fill: transparent;
stroke: #333;
stroke-width: 20;
stroke-dasharray: 534;
transition: stroke-dashoffset 1s;
-webkit-animation-play-state: running;
/* firefox bug fix - won't rotate at 90deg angles */
-moz-transform: rotate(-89deg) translateX(-190px);
}
.chart[data-percent="75"] .outer {
stroke-dashoffset: 133;
//stroke-dashoffset: 50;
-webkit-animation: show75 2s;
animation: show75 2s;
}
#keyframes show75 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 124;
}
}
<div class="container text-center">
<figure class="chart" data-percent="75">
<figcaption>45%</figcaption>
<svg width="200" height="200">
<circle class="outer mr-auto ml-auto" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"></circle>
</svg>
</figure>
</div>
When i resize the circle i got something like this:Resized circle

Don't use a set height or width on the SVG, use the viewbox attribute instead
<svg viewbox="0 0 200 200">
Then the SVG will scale to any size you want just by using a width on the parent container.
The viewBox attribute defines the position and dimension, in user space, of an SVG viewport.
Viewbox # MDN
.container.text-center {
/* for demo */
display: inline-block;
text-align: center;
}
.chart {
position: relative;
display: inline-block;
color: #999;
font-size: 20px;
width: 100px;
/* size here */
}
.chart figcaption {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.outer {
fill: transparent;
stroke: #333;
stroke-width: 20;
stroke-dasharray: 534;
transition: stroke-dashoffset 1s;
-webkit-animation-play-state: running;
/* firefox bug fix - won't rotate at 90deg angles */
-moz-transform: rotate(-89deg) translateX(-190px);
}
.chart[data-percent="75"] .outer {
stroke-dashoffset: 133;
//stroke-dashoffset: 50;
-webkit-animation: show75 2s;
animation: show75 2s;
}
#keyframes show75 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 124;
}
}
.chart.wide {
width: 150px;
}
<div class="container text-center">
<figure class="chart" data-percent="75">
<figcaption>45%</figcaption>
<svg viewbox="0 0 200 200">
<circle class="outer mr-auto ml-auto" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"></circle>
</svg>
</figure>
</div>
<div class="container text-center">
<figure class="chart wide" data-percent="75">
<figcaption>45%</figcaption>
<svg viewbox="0 0 200 200">
<circle class="outer mr-auto ml-auto" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"></circle>
</svg>
</figure>
</div>

Using the transform property you can scale the circle however you want. For example: using transform: scale(0.5,0.5); will scale the circle to half width and height. W3 Schools shows how this works nicely.
However, you can't transform text, so you will have to move it manually.
.chart {
position: relative;
display: inline-block;
color: #999;
font-size: 20px;
text-align: center;
}
.chart figcaption {
position: absolute;
top: 18%;
left: 15%;
}
.outer {
fill: transparent;
stroke: #333;
stroke-width: 20;
stroke-dasharray: 534;
transition: stroke-dashoffset 1s;
-webkit-animation-play-state: running;
/* firefox bug fix - won't rotate at 90deg angles */
-moz-transform: rotate(-89deg) translateX(-190px);
}
.chart[data-percent="75"] .outer {
stroke-dashoffset: 133;
//stroke-dashoffset: 50;
-webkit-animation: show75 2s;
animation: show75 2s;
transform: scale(0.5, 0.5);
}
#keyframes show75 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 124;
}
}
<div class="container text-center">
<figure class="chart" data-percent="75" transform="">
<figcaption>45%</figcaption>
<svg width="200" height="200">
<circle class="outer mr-auto ml-auto" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"></circle>
</svg>
</figure>
</div>

Related

SVG circle not appearing in HTML CSS

I am creating a really simple loader page for my application. I wanted to use a circle, that rotates, and as I saw a tutorial, I used the SVG and circle tags. Here is the code HTML:
<div className="loader">
<svg className="svg">
<circle cx="70" cy="70" height="100px" width="100px" />
</svg>
</div>
And here is all the involved CSS in this case:
.loader{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.svg{
width: 150px;
height: 150px;
animation: rotate 2s linear infinite;
}
#keyframes rotate{
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}
.svg circle{
background-color: red;
width: 1em;
height: 1em;
fill: var(--redwine);
stroke-width: 10;
stroke: var(--redwine);
stroke-linecap: round;
transform:translate(5px, 5px);
stroke-dasharray: 440;
stroke-dashoffset: 440;
animation: circular 4s linear infinite;
z-index: 100;
}
#keyframes circular{
0%, 100%{
stroke-dashoffset: 440;
}
50%{
stroke-dashoffset: 0;
}
50.1%{
stroke-dashoffset: 880;
}
}
The only problem with all this code is that whenever I open the page, to see if all is working, it gives me an empty page. So I try to inspect. When I hover in the browser the code of SVG, it shows the shadow of a square that rotates, but when I hover the circle code, it shows a point with the following label: circle 0x0. I think that it is not rendering correctly, or I am blocking it. I don't really know.
Can someone help? Thank you a lot
You are missing the radius attribute r.
<circle cx="70" cy="70" r="25" height="100px" width="100px" />
See below:
.loader {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.svg {
width: 150px;
height: 150px;
animation: rotate 2s linear infinite;
}
#keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.svg circle {
background-color: red;
width: 1em;
height: 1em;
fill: var(--redwine);
stroke-width: 10;
stroke: var(--redwine);
stroke-linecap: round;
transform: translate(5px, 5px);
stroke-dasharray: 440;
stroke-dashoffset: 440;
animation: circular 4s linear infinite;
z-index: 100;
}
#keyframes circular {
0%,
100% {
stroke-dashoffset: 440;
}
50% {
stroke-dashoffset: 0;
}
50.1% {
stroke-dashoffset: 880;
}
}
<div className="loader">
<svg className="svg">
<circle cx="70" cy="70" r="25" height="100px" width="100px" />
</svg>
</div>

CSS animation on mac vs windows

I'm trying to create a spinner animation but i've encountered some issues with the difference between windows and mac displays.
The animation is a pretty basic circular spinner created with html and css
<div class="cow-spinner">
<span></span>
<span></span>
<span></span>
<span></span>
</div>
and some basic css:
.cow-spinner {
display: inline-block;
position: relative;
width: 64px;
height: 64px;
}
.cow-spinner span {
box-sizing: border-box;
display: block;
position: absolute;
width: 51px;
height: 51px;
margin: 6px;
border: 3px solid black;
border-radius: 50%;
animation: cow-spin 1.2s ease-in-out infinite;
border-color: black transparent transparent transparent;
}
.cow-spinner span:nth-child(1) {
animation-delay: -0.45s;
}
.cow-spinner span:nth-child(2) {
animation-delay: -0.3s;
}
.cow-spinner span:nth-child(3) {
animation-delay: -0.15s;
}
#keyframes cow-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
The animation itself works perfectly, with a working example here: https://codepen.io/fatoilyguy/pen/oaZMMp
My issue is that on mac the circle itself has smooth edges with consistent width like so:
but on windows, the circle is pixelated and has weird width variations:
From what I can see, there is no difference between browsers on either platform. Is there any way i could prevent this difference from happening between platforms?
You could try a SVG approach and check if the rendering it's good everywhere
.loader {
display: inline-block;
height: 100px;
width: 100px;
transform: rotateZ(0deg);
animation: rotate 1.5s linear infinite;
}
svg {
max-width: 140px;
max-height: 140px;
fill: none;
stroke: #9bc;
stroke-width: 5px;
stroke-dasharray: 301px;
stroke-dashoffset: 200px;
animation: path 1.5s linear 0s infinite;
}
#keyframes path {
60% { stroke-dashoffset: 40px; }
100% { stroke-dashoffset: 200px; }
}
#keyframes rotate {
100% { transform: rotateZ(360deg) }
}
<div class="loader">
<svg viewport="0 0 100 100" preserveAspectRatio="xMidYMid meet">
<path d="M 50, 50 m -48, 0 a 48,48 0 1,0 96,0 a 48,48 0 1,0 -96,0" />
</svg>
</div>

Image between 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;
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>

Why does this animation move to the bottom right?

I have been working on this and I'm stuck as to why this animation moves my circles to the bottom right. It pulses and scales properly and at the right times I want, but the circles start in the middle and skew to the bottom right of the div.
I want them to stay centered in the middle of the Div behind the header text
#import url('https://fonts.googleapis.com/css?family=Lobster+Two');
h1 {
font-family: 'Lobster Two', cursive;
font-size: 5rem;
color: #343434;
}
.container {
position: fixed;
z-index: 0;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
overflow: hidden;
}
.pulse {
z-index: -1;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 30rem;
}
.pulse circle {
fill: #ff5154;
transform: scale(0);
opacity: 0;
animation: pulse 2s;
animation-fill-mode: forwards;
transition-timing-function: cubic-bezier(0.5, 0.5, 0, 1);
}
.pulse circle:nth-child(2) {
fill: #7fc6a4;
animation: pulse 2s 1.75;
transition-timing-function: cubic-bezier(0.5, 0.5, 0, 1);
}
.pulse circle:nth-child(3) {
fill: #e5f77d;
animation: pulse 2s 2.00;
transition-timing-function: cubic-bezier(0.5, 0.5, 0, 1);
}
#keyframes pulse {
25% {
opacity: 0.7;
}
100% {
transform: scale(1.05);
}
}
Here is the HTML.
<div class="container">
<h1>Pulse Animation</h1>
<svg class="pulse" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<circle id="Oval" cx="512" cy="512" r="512"></circle>
<circle id="Oval" cx="512" cy="512" r="512"></circle>
<circle id="Oval" cx="512" cy="512" r="512"></circle>
</svg>
</div>
I made a couple of alterations in your CSS to get this to work. I changed the top and left of the pulse class elements to be 0% instead of 50% and then used transform-origin on the circle class elements to center them.
#import url('https://fonts.googleapis.com/css?family=Lobster+Two');
h1 {
font-family: 'Lobster Two', cursive;
font-size: 5rem;
color: #343434;
}
.container {
position: fixed;
z-index: 0;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
overflow: hidden;
}
.pulse {
z-index: -1;
position: fixed;
top: 0%;
left: 0%;
max-width: 30rem;
}
.pulse circle {
fill: #ff5154;
transform: scale(0);
opacity: 0;
animation: pulse 2s;
animation-fill-mode: forwards;
transform-origin: 50% 50%;
transition-timing-function: cubic-bezier(0.5, 0.5, 0, 1);
}
.pulse circle:nth-child(2) {
fill: #7fc6a4;
animation: pulse 2s 1s;
transition-timing-function: cubic-bezier(0.5, 0.5, 0, 1);
}
.pulse circle:nth-child(3) {
fill: #e5f77d;
animation: pulse 2s 2s;
transition-timing-function: cubic-bezier(0.5, 0.5, 0, 1);
}
#keyframes pulse {
25% {
opacity: 0.7;
}
100% {
transform: scale(1.05);
}
}
<div class="container">
<h1>Pulse Animation</h1>
<svg class="pulse" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<circle id="Oval" cx="512" cy="512" r="512"></circle>
<circle id="Oval" cx="512" cy="512" r="512"></circle>
<circle id="Oval" cx="512" cy="512" r="512"></circle>
</svg>
</div>

CSS Progress circle, change percentage

I have found the following code, Link, it works perfectly but the problem is that I can only make the percentage 25, 50 or 75. If I want to make it 85% the circle fills up fully. Anyone any idea what I have to do? Maybe some JavaScript or JQuery that I have to add? Thanks!
Here is the HTML:
/* Import the Google Font 'Lato' */
#import url(http://fonts.googleapis.com/css?family=Lato:300,400,700);
/* Container styles */
body {
background-color: #fff;
color: #333;
font-family: 'Lato';
}
.container {
padding: 50px 0;
text-align: center;
}
.chart {
position: relative;
display: inline-block;
color: #999;
font-size: 20px;
text-align: center;
}
.chart figcaption {
padding: 50px 25px;
width: 100px;
height: 50px;
border: 20px solid #f0f0f0;
border-radius: 100px;
line-height: 50px;
}
.chart img {
position: absolute;
max-width: 100px;
max-height: 100px;
background: white;
}
/* END Container styles */
/* Colors for the circles and positions for the graphics */
.html {
top: 50px;
left: 45px;
}
.html + svg .outer {
stroke: #e34f26;
}
.css {
top: 55px;
left: 48px;
}
.css + svg .outer {
stroke: #0d84ce;
}
.javascript {
max-width: 90px;
max-height: 90px;
top: 45px;
left: 45px;
}
.javascript + svg .outer {
stroke: #f0e040;
}
.node {
width: 200px;
height: 200px;
top: 45px;
left: 45px;
}
.node + svg .outer {
stroke: #83cd29;
}
.chart svg {
position: absolute;
top: 0;
left: 0;
}
.outer {
fill: transparent;
stroke: #333;
stroke-width: 20;
stroke-dasharray: 534;
transition: stroke-dashoffset 1s;
-webkit-animation-play-state: running;
/* firefox bug fix - won't rotate at 90deg angles */
-moz-transform: rotate(-89deg) translateX(-190px);
}
.chart:hover .outer {
stroke-dashoffset: 534 !important;
-webkit-animation-play-state: paused;
}
/* END Circle colors and graphic positions */
/* Set the initial values for the animation */
.chart[data-percent='100'] .outer {
stroke-dashoffset: 0;
-webkit-animation: show100 2s;
animation: show100 2s;
}
.chart[data-percent='75'] .outer {
stroke-dashoffset: 133;
-webkit-animation: show75 2s;
animation: show75 2s;
}
.chart[data-percent='50'] .outer {
stroke-dashoffset: 267;
-webkit-animation: show50 2s;
animation: show50 2s;
}
.chart[data-percent='25'] .outer {
stroke-dashoffset: 401;
-webkit-animation: show25 2s;
animation: show25 2s;
}
/* END set initial animation values */
/* Keyframes for the initial animation */
#-webkit-keyframes show100 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 0;
}
}
#keyframes show100 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes show75 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 134;
}
}
#keyframes show75 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 124;
}
}
#-webkit-keyframes show50 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 267;
}
}
#keyframes show50 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 267;
}
}
#-webkit-keyframes show25 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 401;
}
}
#keyframes show25 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 401;
}
}
/* END Keyframes for the initial animation */
<section class="container">
<h3>I'm a web developer and here's what I can do</h3>
<!-- HTML Chart -->
<div class="chart" data-percent="85">
<figcaption>HTML</figcaption>
<img class="html" src="https://dl.dropboxusercontent.com/s/68gv23q4y5qyq52/html5.svg">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</div>
<!-- CSS Chart -->
<figure class="chart" data-percent="75">
<figcaption>CSS</figcaption>
<img class="css" src="https://dl.dropboxusercontent.com/s/gftbpqje9h2jvlv/css3.svg">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</figure>
<!-- Javascript Chart -->
<figure class="chart" data-percent="50">
<figcaption>Javascript</figcaption>
<img class="javascript" src="https://dl.dropboxusercontent.com/s/jsp3rsberc4q650/javascript.svg">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</figure>
<!-- Node.js Chart -->
<figure class="chart" data-percent="25">
<figcaption>Node</figcaption>
<img class="node" src="https://dl.dropboxusercontent.com/s/v28zws1p38tjph2/node.png">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</figure>
<p>Pure CSS and SVG animation</p>
</section>
Iy's not a script so it's not automatically fit to any percentage. In that pen, the author defined only those 4 percentage. Here I added 85% too. But if you want to do this dynamically, you need to use a script.
Take a look:
/* Import the Google Font 'Lato' */
#import url(http://fonts.googleapis.com/css?family=Lato:300,400,700);
/* Container styles */
body {
background-color: #fff;
color: #333;
font-family: 'Lato';
}
.container {
padding: 50px 0;
text-align: center;
}
.chart {
position: relative;
display: inline-block;
color: #999;
font-size: 20px;
text-align: center;
}
.chart figcaption {
padding: 50px 25px;
width: 100px;
height: 50px;
border: 20px solid #f0f0f0;
border-radius: 100px;
line-height: 50px;
}
.chart img {
position: absolute;
max-width: 100px;
max-height: 100px;
background: white;
}
/* END Container styles */
/* Colors for the circles and positions for the graphics */
.html {
top: 50px;
left: 45px;
}
.html + svg .outer {
stroke: #e34f26;
}
.css {
top: 55px;
left: 48px;
}
.css + svg .outer {
stroke: #0d84ce;
}
.javascript {
max-width: 90px;
max-height: 90px;
top: 45px;
left: 45px;
}
.javascript + svg .outer {
stroke: #f0e040;
}
.node {
width: 200px;
height: 200px;
top: 45px;
left: 45px;
}
.node + svg .outer {
stroke: #83cd29;
}
.chart svg {
position: absolute;
top: 0;
left: 0;
}
.outer {
fill: transparent;
stroke: #333;
stroke-width: 20;
stroke-dasharray: 534;
transition: stroke-dashoffset 1s;
-webkit-animation-play-state: running;
/* firefox bug fix - won't rotate at 90deg angles */
-moz-transform: rotate(-89deg) translateX(-190px);
}
.chart:hover .outer {
stroke-dashoffset: 534 !important;
-webkit-animation-play-state: paused;
}
/* END Circle colors and graphic positions */
/* Set the initial values for the animation */
.chart[data-percent='100'] .outer {
stroke-dashoffset: 0;
-webkit-animation: show100 2s;
animation: show100 2s;
}
.chart[data-percent='85'] .outer {
stroke-dashoffset: 83;
-webkit-animation: show85 2s;
animation: show85 2s;
}
.chart[data-percent='75'] .outer {
stroke-dashoffset: 133;
-webkit-animation: show75 2s;
animation: show75 2s;
}
.chart[data-percent='50'] .outer {
stroke-dashoffset: 267;
-webkit-animation: show50 2s;
animation: show50 2s;
}
.chart[data-percent='25'] .outer {
stroke-dashoffset: 401;
-webkit-animation: show25 2s;
animation: show25 2s;
}
/* END set initial animation values */
/* Keyframes for the initial animation */
#-webkit-keyframes show100 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 0;
}
}
#keyframes show100 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes show85 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 83;
}
}
#keyframes show85 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 83;
}
}
#-webkit-keyframes show75 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 134;
}
}
#keyframes show75 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 124;
}
}
#-webkit-keyframes show50 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 267;
}
}
#keyframes show50 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 267;
}
}
#-webkit-keyframes show25 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 401;
}
}
#keyframes show25 {
from {
stroke-dashoffset: 537;
}
to {
stroke-dashoffset: 401;
}
}
/* END Keyframes for the initial animation */
<section class="container">
<h3>I'm a web developer and here's what I can do</h3>
<!-- HTML Chart -->
<div class="chart" data-percent="85">
<figcaption>HTML</figcaption>
<img class="html" src="https://dl.dropboxusercontent.com/s/68gv23q4y5qyq52/html5.svg">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</div>
<!-- CSS Chart -->
<figure class="chart" data-percent="75">
<figcaption>CSS</figcaption>
<img class="css" src="https://dl.dropboxusercontent.com/s/gftbpqje9h2jvlv/css3.svg">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</figure>
<!-- Javascript Chart -->
<figure class="chart" data-percent="50">
<figcaption>Javascript</figcaption>
<img class="javascript" src="https://dl.dropboxusercontent.com/s/jsp3rsberc4q650/javascript.svg">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</figure>
<!-- Node.js Chart -->
<figure class="chart" data-percent="25">
<figcaption>Node</figcaption>
<img class="node" src="https://dl.dropboxusercontent.com/s/v28zws1p38tjph2/node.png">
<svg width="200" height="200">
<circle class="outer" cx="95" cy="95" r="85" transform="rotate(-90, 95, 95)"/>
</svg>
</figure>
<p>Pure CSS and SVG animation</p>
</section>