CSS3 : appear check mark and text on the same time - html

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>

Related

Blazor, CSS - Keyframes Animation

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>

Need cross instead tick in SVG

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>

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 Firefox replay css animations in reverse?

As shown in the codepen below, the nav a links fade in as they should, but then when hovered they seem to replay the animation in reverse and then forward again really quickly. It's really odd. http://codepen.io/mildrenben/pen/wBMVdm
<header>
<h1>BEN MILDREN</h1>
<p>Designer and Developer</p>
</header>
<nav>
<a>About</a>
<a>Portfolio</a>
<a>Blog</a>
<a>Contact</a>
</nav>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,700,800|Gentium+Book+Basic:400,400italic,700italic' rel='stylesheet' type='text/css'>
CSS:
html, body {
width: 100%;
height: 100%;
}
body {
background: url(https://ununsplash.imgix.net/reserve/D9xlw7UxTBqQw5sLf8cJ_reef%20insp-72.jpg?q=75&fm=jpg&s=a46f72e373f7af2b3bba993f565e24be);
background-size: cover;
}
* {
margin: 0;
}
$color: #4C5C58;
$color-light: #5B6B67;
header {
position: absolute;
top: 27%;
left: calc(50% - 182px);
text-align: center;
-webkit-animation: anim2 1s ease-in-out 2.5s forwards;
}
#-webkit-keyframes anim1 {
100% {
transform: translateY(-12px);
opacity: 1;
}
}
#-webkit-keyframes anim2 {
100% {
transform: translateY(-70px);
}
}
#keyframes anim1 {
100% {
transform: translateY(-12px);
opacity: 1;
}
}
#keyframes anim2 {
100% {
transform: translateY(-70px);
}
}
h1 {
font-family: 'Open Sans', sans-serif;
font-size: 56px;
font-weight: 800;
color: $color;
opacity: 0;
-webkit-animation: anim1 1.5s ease-in-out forwards;
animation: anim1 1.5s ease-in-out forwards;
}
p {
font-family: 'Gentium Book Basic', serif;
font-style: italic;
font-size: 20px;
color: $color-light;
opacity: 0;
-webkit-animation: anim1 1.5s ease-in-out 0.3s forwards;
}
nav {
position: absolute;
left: calc(50% - 183px);
top: 45%;
}
a {
height: 40px;
width: auto;
background: none;
margin: 0 20px;
border: none;
cursor: pointer;
font-family: 'Gentium Book Basic', sans-serif;
font-weight: 500;
font-size: 15px;
color: $color-light;
transition: all 0.3s ease-in-out;
line-height: 50px;
opacity: 0;
display: inline-block;
}
a:hover {
border-bottom: double 3px $color-light;
}
img {
width: 150px;
position: absolute;
margin-left: 72px;
top: 38px;
}
nav p {
font-style: italic;
font-size: 14px;
position: absolute;
top: 80px;
left: 100px;
}
a:nth-of-type(1) {
-webkit-animation: anim1 1s ease-in-out 3s forwards;
animation: anim1 1s ease-in-out 3s forwards;
}
a:nth-of-type(2) {
-webkit-animation: anim1 1s ease-in-out 3.1s forwards;
animation: anim1 1s ease-in-out 3.1s forwards;
}
a:nth-of-type(3) {
-webkit-animation: anim1 1s ease-in-out 3.2s forwards;
animation: anim1 1s ease-in-out 3.2s forwards;
}
a:nth-of-type(4) {
-webkit-animation: anim1 1s ease-in-out 3.3s forwards;
animation: anim1 1s ease-in-out 3.3s forwards;
}

SVG Rotating Dashed Circle Border on Hover

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/>