Spinning Effect Anchor tag CSS3 - html

Helo Guys!
I was trying to create a spinning hover effect with CSS3.
Just made a circle spinning effect. Check the jsFiddle here: http://jsfiddle.net/63yyeezn/26/
However what I want to do now is to create something tthat spins but this time its box type
just like this image:
So basically I want similar effect just like the jsFiddle I shown above however this time it must be box.
Really having a hard time figuring this out. Here's my CSS:
body {
background: #292929;
padding-left: 30px;
font-size: 12px;
}
.twist {
display: inline-block;
font-size: 45px;
line-height: 90px;
cursor: pointer;
margin: 20px;
width: 90px;
height: 90px;
border-radius: 50%;
text-align: center;
position: relative;
text-decoration: none;
z-index: 1;
color: #fff;
}
.twist:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content:'';
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.twist:before {
speak: none;
font-size: 48px;
line-height: 90px;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
display: block;
-webkit-font-smoothing: antialiased;
}
.twist.demo-4 {
width: 92px;
height: 92px;
box-shadow: 0 0 0 4px rgba(255, 255, 255, 1);
}
.twist.demo-4:before {
line-height: 92px;
}
.twist.demo-4:after {
top: -4px;
left: -4px;
padding: 0;
z-index: 10;
border: 4px dashed #fff;
}
.twist.demo-4:hover {
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
color: #fff;
}
.twist.demo-4:hover i {
color: #fff;
}
.twist.demo-4.spin:hover {
-webkit-transition: box-shadow 0.2s;
-moz-transition: box-shadow 0.2s;
transition: box-shadow 0.2s;
}
.twist.demo-4.spin:hover:after {
-webkit-animation: spinAround 9s linear infinite;
-moz-animation: spinAround 9s linear infinite;
animation: spinAround 9s linear infinite;
}
#-webkit-keyframes spinAround {
from {
-webkit-transform: rotate(0deg)
}
to {
-webkit-transform: rotate(360deg);
}
}
#-moz-keyframes spinAround {
from {
-moz-transform: rotate(0deg)
}
to {
-moz-transform: rotate(360deg);
}
}
#keyframes spinAround {
from {
transform: rotate(0deg)
}
to {
transform: rotate(360deg);
}
}
Hope you can help me with a jsFiddle file.
Thanks!

My answer won't fit exactly your example, but may interest you as it's a full-CSS3 solution, without HTML markup change. The animation won't be a rotation, but a translation.
Webkit version
.bordered {
overflow: hidden;
}
.bordered:before {
content: '';
position: absolute;
top: 5px; /* 5px: border width */
left: 5px;
right: 5px;
bottom: 5px;
background: white;
z-index: -1;
}
.bordered:after {
content: '';
position: absolute;
top: -50%;
left: -50%;
right: -50%;
bottom: -50%;
background: black;
z-index: -2;
}
.bordered:hover:after {
background: -webkit-linear-gradient(left, white 50%, black 50%); /* black: border color*/
background-size: 20px 100%; /* 20px: dash width */
-webkit-animation: borderAnimated 1s linear infinite;
}
#-webkit-keyframes borderAnimated {
from {
transform: rotate(45deg) translate(0, 0);
}
to {
transform: rotate(45deg) translate(20px, 0);
}
}
/* --- Style only--- */
.bordered {
width: 150px;
height: 150px;
line-height: 150px;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div class="bordered">Lorem ipsum</div>
The trick is to have a stripped background in the :after pseudo-element, and a fake empty background in the :before element, which will work as a mask. When hovering your element, you just have to animate the :after pseudo-element to get something nice.

Credits: #vsynz
I don't think it can be possible only with static borders. Here is an alternative solution:
.rotating-dashed {
position: relative;
margin: 40px auto;
width: 90px;
height: 90px;
overflow: hidden;
color: #268;
}
.rotating-dashed .dashing {
display: block;
width: 100%;
height: 100%;
position: absolute;
}
.rotating-dashed .dashing:nth-of-type(2) {
-webkit-transform: rotate(90deg);
}
.rotating-dashed .dashing:nth-of-type(3) {
-webkit-transform: rotate(180deg);
}
.rotating-dashed .dashing:nth-of-type(4) {
-webkit-transform: rotate(270deg);
}
.rotating-dashed .dashing i {
display: block;
position: absolute;
left: 0;
top: 0;
width: 200%;
border-bottom: 5px solid
}
.rotating-dashed strong {
display: block;
width: 105%;
line-height: 90px;
text-align: center;
position: absolute;
}
.rotating-dashed:hover {
cursor: pointer;
}
.rotating-dashed:hover .dashing i {
-webkit-animation: slideDash 2.5s infinite linear;
border-bottom: 5px dashed
}
#-webkit-keyframes slideDash {
from {
-webkit-transform: translateX(-50%);
}
to {
-webkit-transform: translateX(0%);
}
}
<div class="rotating-dashed"> <span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<strong>Demo</strong>
</div>

Related

overflow: hidden doesn't work on :after and :before pseudo elements

I am making this rounded scroll down button with an arrow inside. On hover I wanted to apply an animation that makes the arrow go from above to below the rounded div, and it should be hidden when outside the div.
I tried using overflow: hidden but for some reason it doesn't work. Does anyone has a solution for this please?
Codepen: https://codepen.io/RaphaelleD/pen/vYpqxpm
#keyframes tipUp {
0% {
transform: translateY(-10px) rotateZ(225deg);
}
100% {
transform: translateY(100px) rotateZ(225deg);
}
}
#keyframes lineUp {
0% {
transform: translateY(-10px);
}
100% {
transform: translateY(100px);
}
}
.scrolldown {
position: relative;
margin: 0 auto;
}
.scrolldown p {
font-size: 1rem;
font-weight: 600;
padding-bottom: 0.8rem;
text-align: center;
}
.scrolldown__arrow {
width: 6rem;
height: 6rem;
border: 6px solid black;
border-radius: 50%;
margin: 0 auto;
overflow: hidden;
}
.scrolldown__arrow:before {
position: absolute;
display: inline-block;
content: "";
background: black;
width: 10px;
height: 45px;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -5px;
transform: translateY(50px);
}
.scrolldown__arrow:after {
position: absolute;
display: inline-block;
content: "";
width: 22px;
height: 22px;
color: black;
border-top: 9px solid;
border-left: 9px solid;
transform: rotateZ(45deg);
top: 50%;
left: 50%;
margin-top: -30px;
margin-left: -15.5px;
transform: translateY(50px) rotateZ(225deg);
}
.scrolldown__arrow:hover:before {
animation: lineUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
.scrolldown__arrow:hover:after {
animation: tipUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
}
}
<body>
<div class="scrolldown">
<p>SCROLL DOWN</p>
<div class="scrolldown__arrow"></div>
</div>
</body>
I believe this is because of position: absolute, which takes the arrow out of the normal flow. In order to kinda preserve it in the flow, I've added position: relative to the arrow parent, and had to adjust top position as well, seems to work as expected:
#keyframes tipUp {
0% {
transform: translateY(-10px) rotateZ(225deg);
}
100% {
transform: translateY(100px) rotateZ(225deg);
}
}
#keyframes lineUp {
0% {
transform: translateY(-10px);
}
100% {
transform: translateY(100px);
}
}
.scrolldown {
position: relative;
margin: 0 auto;
}
.scrolldown p {
font-size: 1rem;
font-weight: 600;
padding-bottom: 0.8rem;
text-align: center;
}
.scrolldown__arrow {
width: 6rem;
height: 6rem;
border: 6px solid black;
border-radius: 50%;
margin: 0 auto;
overflow: hidden;
position: relative;
}
.scrolldown__arrow:before {
position: absolute;
display: inline-block;
content: "";
background: black;
width: 10px;
height: 45px;
top: 25%;
left: 50%;
margin-top: -50px;
margin-left: -5px;
transform: translateY(50px);
}
.scrolldown__arrow:after {
position: absolute;
display: inline-block;
content: "";
width: 22px;
height: 22px;
color: black;
border-top: 9px solid;
border-left: 9px solid;
transform: rotateZ(45deg);
top: 25%;
left: 50%;
margin-top: -30px;
margin-left: -15.5px;
transform: translateY(50px) rotateZ(225deg);
}
.scrolldown__arrow:hover:before {
animation: lineUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
.scrolldown__arrow:hover:after {
animation: tipUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
}
}
<body>
<div class="scrolldown">
<p>SCROLL DOWN</p>
<div class="scrolldown__arrow"></div>
</div>
</body>

I can't make the 3/4 circle and i have to use one div only so how can i make it as the example in the link below

here is the shape i want to do enter link description here
P.S.I am still learning the front-end stuff so could you pls help me with this assignment.
Here is the HTML code <div>Elzero</div>
here is the CSS code i tried to do with
* {
box-sizing: border-box;
}
div {
width: 200px;
height: 200px;
background-color: #eee;
margin: 80px auto;
color: black;
font-size: 50px;
font-weight: bold;
text-align: center;
line-height: 200px;
border-radius: 50%;
}
::after {
content: "";
width: 200px;
height: 200px;
background-color: #03a9f4;
margin: 80px auto;
border-radius: 50%;
position: absolute;
transform: translate(-190px, -80px);
z-index: -1;
}
::before {
content: "";
width: 200px;
height: 200px;
background-color: #e91e63;
margin: 80px auto;
border-radius: 50%;
position: absolute;
top: 0px;
z-index: -2;
}
div:hover {
transition: all 0.5s;
transform: rotate(180deg);
}
As you are constrained to use just one div, this snippet builds on your idea of having the pseudo elements but creating them with conic-gradient backgrounds and the 'main' div having the light gray circular background created using a radial gradient. That way it creates these 3 shapes.
and overlays them to give the impression of 3/4 circles. It then uses CSS animation to rotate them on hover.
Obviously you will want to play with the dimensions, the animations timings and directions to get exactly what you want but this should give a start.
* {
box-sizing: border-box;
}
div {
width: 200px;
height: 200px;
background-image: radial-gradient(#eee 0 55%, transparent 55% 100%);
margin: 80px auto;
color: black;
font-size: 50px;
font-weight: bold;
text-align: center;
line-height: 200px;
border-radius: 50%;
position: relative;
}
div::after {
content: "";
width: 200px;
height: 200px;
border-radius: 50%;
position: absolute;
top: 0;
left: 0;
z-index: -2;
background-image: conic-gradient(#03a9f4 0deg 45deg, white 45deg 135deg, #03a9f4 135deg 360deg);
}
div::before {
content: "";
width: calc(100% - 10%);
height: calc(100% - 10%);
position: absolute;
border-radius: 50%;
position: absolute;
top: 5%;
left: 5%;
z-index: -1;
background-image: conic-gradient(#e91e63 0, #e91e63 225deg, white 225deg, white 315deg, #e91e63 315deg, #e91e63 360deg);
}
div:hover::after {
animation: rot .4s linear;
}
div:hover::before {
animation: rot .4s linear;
animation-delay: .1s;
animation-direction: reverse;
}
#keyframes rot {
0% {
transform: rotate(0);
}
25% {
transform: rotate(180deg);
}
50% {
transform: rotate(180deg);
}
75% {
transform: rotate(0);
}
100% {}
}
<div>Elzero
</div>
also here is example in less:
https://codepen.io/nikitahl/pen/XooBXd
if you want to use css here is a converter:
https://jsonformatter.org/less-to-css

Animating arrow keeps going outside of my div when my height is set to auto

I am having an issue where my animating arrow is going outside of my div when the height is set to auto. Is there any way to prevent the arrow from going outside of the div, while maintaining the height as auto (for responsive purposes)? Any help would be much appreciated.
When I set the height to a fixed height, for example: 300px, the animating arrow completely disappears when it comes to responsiveness; hence, I want to keep the height as auto, while preventing it from going outside of the div.
.title-container-main {
margin-top: 40px;
margin-left: auto;
margin-right: auto;
position: relative;
width: 83%;
height: auto;
background-color: green;
overflow: auto;
}
.title-main{
margin-top: 0px;
padding-top: 12px;
text-align: center;
font-family: myFirstFont;
font-size: 36px;
font-weight: lighter;
color: #7f1146;
letter-spacing: 3.5px;
margin-bottom: 40px;
background-color: white;
}
.title-main::after {
display: block;
content: '';
background-color: #7f1146;
height: 1.5px;
width: 8%;
margin: 13px auto 0 auto;
}
.title-container-text{
line-height: 1.5em;
width: 80%;
margin-left: auto;
margin-right: auto;
text-align: center;
font-weight: bold;
color: #674965;
position: relative;
font-family: mySecondFont;
font-size: 18px;
text-transform: none;
background-color: white;
}
a.active:after {
display: block;
content: '';
background-color: white;
height: 1.5px;
width: 100%;
margin: 2px auto 0 auto;
}
.scroll-down {
margin-left: auto;
margin-right: auto;
margin-top: 45px;
position: relative;
display: block;
text-align: center;
font-size: 20px;
z-index: 100;
text-decoration: none;
text-shadow: 0;
width: 25px;
height: 25px;
border-bottom: 2px solid #7f1146;
border-right: 2px solid #7f1146;
z-index: 9;
-webkit-transform: translate(-50%, 0%) rotate(45deg);
-moz-transform: translate(-50%, 0%) rotate(45deg);
transform: translate(-50%, 0%) rotate(45deg);
-webkit-animation: fade_move_down 4s ease-in-out infinite;
-moz-animation: fade_move_down 4s ease-in-out infinite;
animation: fade_move_down 4s ease-in-out infinite;
}
/*animated scroll arrow animation*/
#-webkit-keyframes fade_move_down {
0% { -webkit-transform:translate(0,-10px) rotate(45deg); opacity: 0; }
50% { opacity: 1; }
100% { -webkit-transform:translate(0,10px) rotate(45deg); opacity: 0; }
}
#-moz-keyframes fade_move_down {
0% { -moz-transform:translate(0,-10px) rotate(45deg); opacity: 0; }
50% { opacity: 1; }
100% { -moz-transform:translate(0,10px) rotate(45deg); opacity: 0; }
}
#keyframes fade_move_down {
0% { transform:translate(0,-10px) rotate(45deg); opacity: 0; }
50% { opacity: 1; }
100% { transform:translate(0,10px) rotate(45deg); opacity: 0; }
}
<div class="title-container-main">
<h2 class="title-main">TREATMENTS</h2>
<p class="title-container-text">Some text.
<div class="scroll-down"></div>
</div>
I suggest you use the .scroll-down container as a placeholder and you set the dimensions. The width can be 100% and the height needed is easily calculated:
element_height (25px) + translation_top (10px) + translation_bot (10px) = 45px
In addition, you can use a pseudo-element (e.g. :after) to draw the arrow. We can use absolute positioning, therefore, it will not interfere with the height:
.title-container-main {
margin-top: 40px;
margin-left: auto;
margin-right: auto;
width: 83%;
height: auto;
background-color: green;
overflow: auto;
text-align: center;
z-index: 1;
}
.title-main {
margin-top: 0px;
padding-top: 12px;
text-align: center;
font-family: myFirstFont;
font-size: 36px;
font-weight: lighter;
color: #7f1146;
letter-spacing: 3.5px;
margin-bottom: 40px;
background-color: white;
}
.title-main::after {
display: block;
content: '';
background-color: #7f1146;
height: 1.5px;
width: 8%;
margin: 13px auto 0 auto;
}
.title-container-text {
line-height: 1.5em;
width: 80%;
margin-left: auto;
margin-right: auto;
text-align: center;
font-weight: bold;
color: #674965;
position: relative;
font-family: mySecondFont;
font-size: 18px;
text-transform: none;
background-color: white;
}
a.active:after {
display: block;
content: '';
background-color: white;
height: 1.5px;
width: 100%;
margin: 2px auto 0 auto;
}
.scroll-down {
position: relative;
width: 100%;
height: 45px;
z-index: 1;
}
.scroll-down:after {
position: absolute;
content: '';
font-size: 20px;
z-index: -1;
text-decoration: none;
text-shadow: 0;
width: 25px;
height: 25px;
margin-left: -14px;
border-bottom: 2px solid #7f1146;
border-right: 2px solid #7f1146;
-webkit-transform: translate(0%, 0%) rotate(45deg);
-moz-transform: translate(0%, 0%) rotate(45deg);
transform: translate(0%, 0%) rotate(45deg);
-webkit-animation: fade_move_down 4s ease-in-out infinite;
-moz-animation: fade_move_down 4s ease-in-out infinite;
animation: fade_move_down 4s ease-in-out infinite;
}
/*animated scroll arrow animation*/
#-webkit-keyframes fade_move_down {
0% {
-webkit-transform: translate(0, -10px) rotate(45deg);
opacity: 0;
}
50% {
opacity: 1;
}
100% {
-webkit-transform: translate(0, 10px) rotate(45deg);
opacity: 0;
}
}
#-moz-keyframes fade_move_down {
0% {
-moz-transform: translate(0, -10px) rotate(45deg);
opacity: 0;
}
50% {
opacity: 1;
}
100% {
-moz-transform: translate(0, 10px) rotate(45deg);
opacity: 0;
}
}
#keyframes fade_move_down {
0% {
transform: translate(0, -10px) rotate(45deg);
opacity: 0;
}
50% {
opacity: 1;
}
100% {
transform: translate(0, 10px) rotate(45deg);
opacity: 0;
}
}
<div class="title-container-main">
<h2 class="title-main">TREATMENTS</h2>
<p class="title-container-text">Some text.</p>
<div class="scroll-down"></div>
</div>

icon cannot be affected when hover

When hover, I would like to translate an icon but CSS is not be effectible to it.
#humberger {
position: relative;
height: 24px;
width: 24px;
display: inline-block;
box-sizing: border-box;
}
#humberger div {
position: absolute;
left: 0;
height: 4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
}
#humberger div:nth-of-type(1) {
top: 0;
}
#humberger div:nth-of-type(2) {
top: 10px;
}
#humberger div:nth-of-type(3) {
bottom: 0;
}
#humberger:hover {
div:nth-of-type(1) {
transform: rotate(20deg);
}
div:nth-of-type(2) {
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
div:nth-of-type(3) {
transform: rotate(-20deg);
}
}
<div id="humberger">
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
</div>
<span class='icon-title'>Open</span>
I am expecting the translation like below.
If someone gave me any knowledge to solve this, I would be very happy.
I think your CSS notation is not valid.
Try this structure instead:
#humberger:hover > div:nth-of-type(1){
transform: rotate(20deg);
cursor: pointer;
}
(tested and works)
Plz try this code..
css
#humberger div{
position: absolute;
left:0;
height:4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
transition: 0.5s all ease 0s;
}
#humberger:hover div {
transition: 0.5s all ease 0s;
}
#humberger div:nth-of-type(1){
top:0;
}
#humberger div:nth-of-type(2) {
top: 10px;
}
#humberger div:nth-of-type(3) {
bottom:0;
}
#humberger:hover div:nth-of-type(1){
transform: rotate(45deg);
top: 10px;
}
#humberger:hover div:nth-of-type(2){
background: rgba(255, 255, 255, 0);
}
#humberger:hover div:nth-of-type(3){
transform: rotate(-45deg);
bottom: 10px;
}
Add transition time & transition-origin and adjust the degree of rotation.
#humberger div{
position: absolute;
left:0;
height:4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
transition: .2s; /*Add transition time*/
transform-origin: 100% center; /*Add transform origin*/
}
#humberger:hover{
div:nth-of-type(1){
transform: rotate(-55deg); /*Adjust angle*/
}
div:nth-of-type(2){
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
div:nth-of-type(3){
transform: rotate(55deg); /*Adjust angle*/
}
}
kindly follow the SASS Structure.
this is the SASS Code for your structure:
#humberger {
position: relative;
height: 24px;
width: 24px;
display: inline-block;
box-sizing: border-box;
div{
position: absolute;
left:0;
height:4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
transition: all 0.3s;
&:nth-of-type(1){
top:0;
}
&:nth-of-type(2) {
top: 10px;
}
&:nth-of-type(3) {
bottom:0;
}
}
&:hover{
div{
&:nth-of-type(1){
transform: rotate(45deg);
top: 0;
bottom: 0;
margin: auto;
}
&:nth-of-type(2){
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
&:nth-of-type(3){
transform: rotate(-45deg);
top: 0;
bottom: 0;
margin: auto;
}
}
}
}
this is the code snippet with normal css.
#humberger {
position: relative;
height: 24px;
width: 24px;
display: inline-block;
box-sizing: border-box;
}
#humberger div {
position: absolute;
left: 0;
height: 4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
#humberger div:nth-of-type(1) {
top: 0;
}
#humberger div:nth-of-type(2) {
top: 10px;
}
#humberger div:nth-of-type(3) {
bottom: 0;
}
#humberger:hover div:nth-of-type(1) {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
top: 0;
bottom: 0;
margin: auto;
}
#humberger:hover div:nth-of-type(2) {
-webkit-transform: translateX(100px);
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
#humberger:hover div:nth-of-type(3) {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
top: 0;
bottom: 0;
margin: auto;
}
<div id="humberger">
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
</div>
<span class='icon-title'>Open</span>
the above SASS code is work same like the Snippet.
I hope this answer will helpful to you.
Thank You...

Css animation does not work in Google Chrome?

I have some css animation fro spinner, but i can not make it work in Google Chrome, i have read a lot of post and find that i missing keyframe rule for WebKit browsers but i dont know how to make it
Here is my css and html
#keyframes spin {
to { transform: rotate(1turn); }
}
.progress-loading {
position: relative;
display: inline-block;
width: 5em;
height: 5em;
margin: 0 .5em;
font-size: 12px;
text-indent: 999em;
overflow: hidden;
animation: spin 1s infinite steps(8);
}
.small.progress-loading {
font-size: 6px;
}
.large.progress-loading {
font-size: 24px;
}
.progress-loading:before,
.progress-loading:after,
.progress-loading > div:before,
.progress-loading > div:after {
content: '';
position: absolute;
top: 0;
left: 2.25em; /* (container width - part width)/2 */
width: .5em;
height: 1.5em;
border-radius: .2em;
background: #eee;
box-shadow: 0 3.5em #eee; /* container height - part height */
transform-origin: 50% 2.5em; /* container height / 2 */
}
.progress-loading:before {
background: #555;
}
.progress-loading:after {
transform: rotate(-45deg);
background: #777;
}
.progress-loading > div:before {
transform: rotate(-90deg);
background: #999;
}
.progress-loading > div:after {
transform: rotate(-135deg);
background: #bbb;
}
HTML
<div class="small progress-loading"><div>Loading…</div></div>
And working fiddle, please chek in chrome it does not work :(
http://fiddle.jshell.net/ynoLjs1c/3/
You are missing -webkit- prefixes. Always check browser support.
#keyframes spin {
to {
transform: rotate(1turn);
}
}
#-webkit-keyframes spin {
to {
-webkit-transform: rotate(1turn);
transform: rotate(1turn);
}
}
.progress-loading {
position: relative;
display: inline-block;
width: 5em;
height: 5em;
margin: 0 .5em;
font-size: 12px;
text-indent: 999em;
overflow: hidden;
-webkit-animation: spin 1s infinite steps(8);
animation: spin 1s infinite steps(8);
}
.small.progress-loading {
font-size: 6px;
}
.large.progress-loading {
font-size: 24px;
}
.progress-loading:before,
.progress-loading:after,
.progress-loading > div:before,
.progress-loading > div:after {
content: '';
position: absolute;
top: 0;
left: 2.25em;
/* (container width - part width)/2 */
width: .5em;
height: 1.5em;
border-radius: .2em;
background: #eee;
box-shadow: 0 3.5em #eee;
/* container height - part height */
transform-origin: 50% 2.5em;
/* container height / 2 */
}
.progress-loading:before {
background: #555;
}
.progress-loading:after {
transform: rotate(-45deg);
background: #777;
}
.progress-loading > div:before {
transform: rotate(-90deg);
background: #999;
}
.progress-loading > div:after {
transform: rotate(-135deg);
background: #bbb;
}
<div class="small progress-loading">
<div>Loading…</div>
</div>