I need to convert the tick mark to a cross mark, I have no knowledge of SVG, so anyone can convert the following tick animation to a cross animation?
body {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.checkmark {
width: 56px;
height: 56px;
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"><circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/></svg>
I have tried my best but the tick join point doesn't splits, tick tail and head attached, any help will be appreciated.
My thought process:
Not really a StackOverflow-worthy question...
But I am a sucker for SVG
I'm gonna do it anyway.
So here you go! I've just changed the <path /> for you.
d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"
Start in the top-left (at 14.1,14.1), go diagonally down-right for 23.8 units, then "pick up the pen" and move 23.8 units up before going down-left for 23.8 units.
Looks good to me!
body {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.checkmark {
width: 56px;
height: 56px;
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"><circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="checkmark__check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/></svg>
Related
I'm using this CSS checkmark animation I found for a success page. It works well, but a bit small. I'd like to increase it in size to about 300 pixels.
I tried increasing the viewBox size to 300, but it didn't work:
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
</svg>
What is the correct way to increase the size?
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark {
width: 56px;
height: 56px;
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
</svg>
I've left three comments below indicating the sizes you need to increase, all in CSS:
The SVG width
The SVG height
The shadow "fill" in the animation (set to 50% the size of the width/height)
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark {
width: 200px; /* 1. change the width here */
height: 200px; /* 2. change the height here */
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%,
100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
/* 3. change the shadow spread-radius here to 50% the width/height */
box-shadow: inset 0px 0px 0px 100px #7ac142;
}
}
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
</svg>
I made an animation in CSS for a check (right or wrong). The animation is actually the same, only the color is different. My problem now is that the name of the "Keyframes Fill" class is the same ("100%"). So both have the same color in the Fill animation. Is it possible to fix this problem somehow ?
Thanks.
/*=========================================
Checkmark Green Animation
=========================================
*/
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark {
width: 32px;
height: 32px;
border-radius: 50%;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
/*=========================================
Checkmark Red Animation
=========================================
*/
.checkmark__circle_red {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #ff0000;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark_red {
width: 32px;
height: 32px;
border-radius: 50%;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
box-shadow: inset 0px 0px 0px #ff0000;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check_red {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke{
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale{
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #ff0000;
}
}
<!--Here is actually a C# check made (a function is called), depending on whether the entered is correct or incorrect.-->
<svg class="checkmark" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
</svg>
<svg class="checkmark_red" viewBox="0 0 52 52">
<circle class="checkmark__circle_red" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check_red" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>
</svg>
Is this the result you wanted? If so, do not set the color in the animation, but before. Sadly there is no box-shadow-color property, but you can use color property. see this SO answer
/*=========================================
Checkmark Green Animation
=========================================
*/
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark {
width: 32px;
height: 32px;
border-radius: 50%;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
color: #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
/*=========================================
Checkmark Red Animation
=========================================
*/
.checkmark__circle_red {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #ff0000;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark_red {
width: 32px;
height: 32px;
border-radius: 50%;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
margin: 10% auto;
color: #ff0000;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__check_red {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke{
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale{
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px;
}
}
<svg class="checkmark" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
</svg>
<svg class="checkmark_red" viewBox="0 0 52 52">
<circle class="checkmark__circle_red" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check_red" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>
</svg>
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>
I have a button with check mark and text.I want check mark and text to be appeared on the same time. in my code I get text to be appeared early than check mark.
.sending_btn {
outline: none;
width: 128px;
height: 30px;
border-radius: 2px;
border: thin #3a3f51 solid;
transform-origin: center center;
}
.sending_btn span {
color: #3a3f51;
}
.sending_btn:focus, .sending_btn:active {
padding: 0;
}
svg{
vertical-align:middle;
}
.svg-success {
stroke-width: 2px;
stroke: #3a3f51;
fill: none;
}
.svg-success path {
stroke-dasharray: 17px, 17px;
stroke-dashoffset: 0px;
-webkit-animation: checkmark 0.25s ease-in-out 0.2s backwards;
animation: checkmark 0.25s ease-in-out 0.2s backwards;
}
.svg-success circle {
stroke-dasharray: 76px, 76px;
stroke-dashoffset: 0px;
transform: rotate(-90deg);
transform-origin: 50% 50%;
-webkit-animation: checkmark-circle 0.6s ease-in-out forwards;
animation: checkmark-circle 0.6s ease-in-out forwards;
}
#keyframes checkmark {
0% {
stroke-dashoffset: 17px;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes checkmark-circle {
0% {
stroke-dashoffset: 76px;
}
100% {
stroke-dashoffset: 0px;
}
}
<button type="button" name="button" class="sending_btn bg-white-only m-t-25px" *ngIf="show_btn == true">
<svg class="v-middle" width="26" height="26" viewBox="-263.5 236.5 26 26">
<g class="svg-success">
<circle cx="-250.5" cy="249.5" r="12"/>
<path d="M-256.46 249.65l3.9 3.74 8.02-7.8"/>
</g>
</svg>
<span class=""> Saved</span></button>
check mark and text should be appeared on the same time and completed on the same time as well.
Any help would be great.
Thank You.
you need to set-up some animation also for the span tag
.sending_btn {
outline: none;
width: 128px;
height: 30px;
border-radius: 2px;
border: thin #3a3f51 solid;
transform-origin: center center;
}
.sending_btn span {
color: #3a3f51;
animation: 1.2s fadeIn;
animation-fill-mode: forwards;
opacity: 0;
}
.sending_btn:focus, .sending_btn:active {
padding: 0;
}
svg{
vertical-align:middle;
}
.svg-success {
stroke-width: 2px;
stroke: #3a3f51;
fill: none;
}
.svg-success path {
stroke-dasharray: 17px, 17px;
stroke-dashoffset: 0px;
-webkit-animation: checkmark 0.25s ease-in-out 0.2s backwards;
animation: checkmark 0.25s ease-in-out 0.2s backwards;
}
.svg-success circle {
stroke-dasharray: 76px, 76px;
stroke-dashoffset: 0px;
transform: rotate(-90deg);
transform-origin: 50% 50%;
-webkit-animation: checkmark-circle 0.6s ease-in-out forwards;
animation: checkmark-circle 0.6s ease-in-out forwards;
}
#keyframes checkmark {
0% {
stroke-dashoffset: 17px;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes checkmark-circle {
0% {
stroke-dashoffset: 76px;
}
100% {
stroke-dashoffset: 0px;
}
}
#keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<button type="button" name="button" class="sending_btn bg-white-only m-t-25px" *ngIf="show_btn == true">
<svg class="v-middle" width="26" height="26" viewBox="-263.5 236.5 26 26">
<g class="svg-success">
<circle cx="-250.5" cy="249.5" r="12"/>
<path d="M-256.46 249.65l3.9 3.74 8.02-7.8"/>
</g>
</svg>
<span class=""> Saved</span></button>
I am trying to create an SVG Hover Animation Effect using CSS.
What I want to do attain is that when I hover on my Icon the solid circle container will rotate with a dashed container. See image below.
Check out what I have done so far: http://jsfiddle.net/uhkwLuph/3/
So far here's my code.
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="200px"
height="200px" viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve" id="icon">
<style type="text/css">
.st0
{
fill:none;
stroke:#F2F2F2;
stroke-width:4;
stroke-miterlimit:10;
}
#icon .st0{
-webkit-transition: .5s;
}
#icon:hover .st0{
fill: #ffffff;
stroke: #1f8a4c;
cursor: pointer;
}
</style>
<g id="container">
<circle class="st0" cx="101" cy="99" r="89.333"/>
</g>
<g id="icon-details">
<path class="st0" d="M146.899,134.202c3.856,4.702,2.772,11.963-2.418,16.218l0,0c-5.192,4.258-12.523,3.896-16.38-0.806
l-30.004-36.594c-3.855-4.701-2.772-11.964,2.418-16.22l0,0c5.19-4.256,12.523-3.895,16.377,0.808L146.899,134.202z"/>
<circle class="st0" cx="77.843" cy="72.434" r="33.331"/>
<circle class="st0" cx="77.844" cy="72.434" r="22.343"/>
</g>
</svg>
I understand that it can be attain with stroke-dasharray and stroke-offset + #Keyframes (CSS) but can anyone point me how we can implement it?
Here's the JSFIDDLE:
Fiddle: Click
Now you just have to play with the dashoffset/dasharray values.
CSS:
body { background: #27ae60; }
#container{
}
#container:hover circle{
animation: dash 2s linear forwards;
-webkit-animation: dash 2s linear forwards;
}
#keyframes dash {
0%{ stroke-dashoffset:0;
stroke-dasharray:0;}
100% {
stroke-dashoffset:10;
stroke-dasharray:180;
}
}
#-webkit-keyframes dash {
0%{ stroke-dashoffset:0;
stroke-dasharray:0;}
100% {
stroke-dashoffset:10;
stroke-dasharray:180;
}
}
UPDATE
:root { background: #27ae60; transition: background .3s ease}
[class=loop]{
position:relative;
margin: 240px auto
}
[class=loop], [class=circle]{
width: 240px;
height: 240px
}
[class=loop]:before, [class=loop]:after{
content: '';
z-index: 1
}
[class=loop]:before, [class=loop]:after,[class=circle]{
position: absolute;
}
[class=loop]:after,[class=circle]{
border-radius: 50%
}
[class=loop]:before{
width: 80px;
height: 20px;
border-radius: 10px;
border: 4px solid green;
transform: rotateZ(50deg);
top: 160px;
left: 114px
}
[class=loop]:after{
top: 32px;
left: 32px;
width: 100px;
height: 100px;
border: 10px solid transparent;
box-shadow: inset 0 0 0 4px green,0 0 0 4px green
}
[class=circle]{
border: 4px dashed green;
top: 0px;
left: 0px;
background: white;
z-index: 0;
background-clip: content-box
}
[class=loop]:hover [class=circle]{
-webkit-animation: spin 1s infinite linear;
-moz-animation: spin 1s infinite linear;
animation: spin 1s infinite linear
}
#-webkit-keyframes spin {
to { transform: rotate(360deg); }
}
#-moz-keyframes spin {
to { transform: rotate(360deg); }
}
#keyframes spin {
to { transform: rotate(360deg); }
}
<div class=loop>
<div class=circle></div>
</div>
Single element solution would be
:root { background: #27ae60; transition: background .3s ease}
:root:hover { background: red }
div{
width: 80px;
height: 20px;
border-radius: 10px;
border: 4px solid white;
transform: rotateZ(45deg);
margin: 230px auto;
position: relative
}
div:before,div:after{
content: '';
position: absolute;
border-radius: 50%
}
div:before{
width: 100px;
height: 100px;
border: 10px solid transparent;
top: -52px;
left: -124px;
box-shadow: inset 0 0 0 4px white,0 0 0 4px white
}
div:after{
width: 250px;
height: 250px;
border: 4px dashed white;
top: -124px;
left: -154px
}
div:hover:after{
-webkit-animation: spin 1s infinite linear;
-moz-animation: spin 1s infinite linear;
animation: spin 1s infinite linear;
}
#-webkit-keyframes spin {
to { transform: rotate(360deg); }
}
#-moz-keyframes spin {
to { transform: rotate(360deg); }
}
#keyframes spin {
to { transform: rotate(360deg); }
}
<div/>