loading - css

HTML

<div class="box">
    <div class="x"></div>
    <div class="xy"></div>
    <div class="y"></div>
    <div class="yx"></div>
</div>

CSS

/* from 四姐 */
@-webkit-keyframes rot {
    0% {
        -webkit-transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
    }
}

.box {
    margin: 0 auto;
    position: relative;
    width: 50px;
    height: 50px;
    -webkit-animation: rot 2s linear infinite;
}
div.x, div.y, div.xy, div.yx {
    position: absolute;
    top: 0;
    left: 50%;
    height: 100%;
    width: 10%;
    border-radius: 5px;
    margin-left: -5%;
    -webkit-transform-origin: 50% 50%;
}

.x {
    background: -webkit-linear-gradient( top, #000 25%, #fff 25%, #fff 75%, #ccc 75% );
    -webkit-transform: rotate(0);
}

.xy {
    background: -webkit-linear-gradient( top, #333 25%, #fff 25%, #fff 75%, #ccc 75% );
    -webkit-transform: rotate(45deg);
}

.y {
    background: -webkit-linear-gradient( top, #666 25%, #fff 25%, #fff 75%, #ccc 75% );
    -webkit-transform: rotate( 90deg );
}

.yx {
    background: -webkit-linear-gradient( top, #999 25%, #fff 25%, #fff 75%, #ccc 75% );
    -webkit-transform: rotate(135deg);
}

JavaScript

animation-name: rot;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: normal/reverse/alternate/alternate-reverse;
animation-play-state: running/paused;
animation-delay: 0s;
animation-fill-mode: none/forwards/backwards/both;


animation: name duration function count direction play-state delay fill-mod;