Simple CSS3 Loading indicator

by TastyBytes

HTML

<div class="loading-icon"></div>

CSS

@-webkit-keyframes loading-slide-before {
    0% {
        left: 0%;
    }
    100% {
        left: 100%;
    }
}

@-webkit-keyframes loading-slide-after {
    0% {
        left: -100%;
    }
    100% {
        left: 0%;
    }
}

.loading-icon {
    border: 1px solid #aaa;
    height: 5px;
    width: 200px;
    position: relative;
    overflow: hidden;
    background: #eee
}

.loading-icon:before, .loading-icon:after {
    position: absolute;
    width: 50%;
    height: 100%;
    -webkit-animation: loading-slide-before 3s infinite linear;
    background: #ccc;
    left: -100%;
    top: 0;
    content: '';
}

.loading-icon:after {
    -webkit-animation: loading-slide-after 3s infinite linear;
}