Check out my CSS below:
#load-icon
{
background: url(/Images/loaders/mask-loader.gif);
background-repeat: no-repeat;
z-index: 99; width: 32px; height: 32px;
z-index: 99;
margin-top: 9px;
margin-bottom: 9px;
margin-right: 5px;
display: none;
}
I've been using this code to show and hide it:
$(document).ajaxStart(function () {
$('#load-icon').show(500);
});
$(document).ajaxStop(function () {
$('#load-icon').hide();
});
However, when hidden, #load-icon doesn't take up space due to the background, which is not the desired behavior.
Is there a way for #load-icon to always occupy 32px of space while making the GIF visible or invisible? I don't mind removing the fade-in or fade-out effects.
Take a look at this fiddle to see where it's used: fiddle
Update: I need a solution that doesn't involve toggling the background image. I want the GIF to remain visible or invisible without specifying its name in the JavaScript, as I may be using different CSS styles.