LESS

// unveil image loading
img.unveil-is-loading {

  @keyframes spinner {
    to {transform: rotate(360deg);}
  }

  &:before {
    content: '';
    box-sizing: border-box;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border-radius: 50%;
    border: 2px solid #ccc;
    border-top-color: #333;
    animation: spinner .6s linear infinite;
    text-indent: 100%;
    white-space: nowrap;
    overflow: hidden;
  }
}

JS

$("img").unveil(10, function () {
    $(this).load(function () {
        $(this).removeClass('unveil-is-loading');
    });
});

Image

<img src="#" data-src="[MY_IMAGE]" class="unveil-is-loading">

 

 

Categories: CSS