CSS代码:
.loadding-circle {
display: inline-block;
width: 30px;
height: 30px;
opacity: 0.75;
margin: 0;
background: none;
}
.loadding-circle {
-webkit-animation: clockwise 600ms ease-out infinite;
animation: clockwise 600ms ease-out infinite;
}
.loadding-circle .circle-cut {
/*
The idea of animating inner circle is based on Polymer ("material") loading indicator
by Keanu Lee https://blog.keanulee.com/2014/10/20/the-tale-of-three-spinners.html
*/
position: relative;
display: inline-block;
width: 20px;
height: 30px;
overflow: hidden;
}
.loadding-circle .circle-donut {
position: absolute;
top: 0;
left: 0;
display: inline-block;
width: 30px;
height: 30px;
margin: 0;
border: 2px solid #000;
border-radius: 50%;
border-left-color: transparent;
border-bottom-color: transparent;
background: none;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.loadding-circle .circle-donut {
-webkit-animation: donut-rotate 1200ms cubic-bezier(0.4, 0, 0.22, 1) infinite;
animation: donut-rotate 1200ms cubic-bezier(0.4, 0, 0.22, 1) infinite;
}
@-webkit-keyframes clockwise {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes clockwise {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-webkit-keyframes donut-rotate {
0% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
50% {
-webkit-transform: rotate(-140deg);
transform: rotate(-140deg);
}
100% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
}
@keyframes donut-rotate {
0% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
50% {
-webkit-transform: rotate(-140deg);
transform: rotate(-140deg);
}
100% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
}
HTML代码:
<div class="loadding-circle">
<span class="circle-cut">
<span class="circle-donut"></span>
</span>
</div>