JSFiddle - React, Tailwind, and code Playground
HTML
<div id="a" class="box">A</div>
<div id="b" class="box">B</div>
<div id="c" class="box">C</div>
CSS
.box {
float:left;
width:100px;
height:100px;
border:1px solid #bbb;
margin: 10px;
padding:20px;
text-align:center;
border-radius:10px;
background: #eee;
position: relative;
}
.loading-centered
{
background:url('http://www.ajaxload.info/images/exemples/24.gif') center center no-repeat white;
position:absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
border-radius:10px;
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
}
JavaScript
$.fn.loading = function(show){
if(show){
this.prepend('<div class="loading-centered"></div>');
}else{
this.children('.loading-centered').remove();
}
};
$('#a').loading(true); //start
setInterval(function(){ $('#a').loading(false); }, 3000); // stop