In the past, i used to use a .gif file to create an animated spinner or loader form my ajax calls.
today, you dont have to use images, you can use css code,
i got this code for my notes just incase i need it in the future, here is the CSS code to create a spinner:
Usage: <div class="spinner-loader"></div>
CSS CODE:
/*SPINNER START
usage: <div class="spinner-loader">Loading…</div>
source:
http://www.css-spinners.com/spinner/spinner
http://www.css-spinners.com/css/spinner/spinner.css
*/
.spinner-loader{ text-align:center; }
@-moz-keyframes spinner-loader {
0% {
-moz-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-webkit-keyframes spinner-loader {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes spinner-loader {
0% {
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
/* :not(:required) hides this rule from IE9 and below */
.spinner-loader:not(:required) {
-moz-animation: spinner-loader 1500ms infinite linear;
-webkit-animation: spinner-loader 1500ms infinite linear;
animation: spinner-loader 1500ms infinite linear;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
border-radius: 0.5em;
-moz-box-shadow: rgba(255,255,255, 1.0) 1.5em 0 0 0, rgba(255,255,255, 1.0) 1.1em 1.1em 0 0, rgba(255,255,255, 1.0) 0 1.5em 0 0, rgba(255,255,255, 1.0) -1.1em 1.1em 0 0, rgba(255,255,255, 1.0) -1.5em 0 0 0, rgba(255,255,255, 1.0) -1.1em -1.1em 0 0, rgba(255,255,255, 1.0) 0 -1.5em 0 0, rgba(255,255,255, 1.0) 1.1em -1.1em 0 0;
-webkit-box-shadow: rgba(255,255,255, 1.0) 1.5em 0 0 0, rgba(255,255,255, 1.0) 1.1em 1.1em 0 0, rgba(255,255,255, 1.0) 0 1.5em 0 0, rgba(255,255,255, 1.0) -1.1em 1.1em 0 0, rgba(255,255,255, 1.0) -1.5em 0 0 0, rgba(255,255,255, 1.0) -1.1em -1.1em 0 0, rgba(255,255,255, 1.0) 0 -1.5em 0 0, rgba(255,255,255, 1.0) 1.1em -1.1em 0 0;
box-shadow: rgba(255,255,255, 1.0) 1.5em 0 0 0, rgba(255,255,255, 1.0) 1.1em 1.1em 0 0, rgba(255,255,255, 1.0) 0 1.5em 0 0, rgba(255,255,255, 1.0) -1.1em 1.1em 0 0, rgba(255,255,255, 1.0) -1.5em 0 0 0, rgba(255,255,255, 1.0) -1.1em -1.1em 0 0, rgba(255,255,255, 1.0) 0 -1.5em 0 0, rgba(255,255,255, 1.0) 1.1em -1.1em 0 0;
display: inline-block;
width: 1em;
height: 1em;
margin: 1.5em;
overflow: hidden;
text-indent: 100%;
}
/*SPINNER END*/