// loader (after submit)
$('input[type="button"]').on('click', function(e) {
\t \t //display loader
screenLoader_Global();
\t \t //just for testing, remove loader
setTimeout(function() {
remove_screenLoader_Global();
}, 3000);
});
/*-----------------------------------------------------
\t \t global screen loader add/remove
\t ------------------------------------------------------*/
function screenLoader_Global() {
$('<div class="loader-mask"><div class="loader"></div></div>').appendTo('body');
}
function remove_screenLoader_Global() {
$('.loader-mask').remove();
}
/*-----------------------------------------------
\t css loader (slack style)
-----------------------------------------------*/
.loader {
position: relative;
width: 5em;
height: 5em;
transform: rotate(165deg);
}
.loader:before,
.loader:after {
content: '';
position: absolute;
top: 50%;
left: 50%;
display: block;
width: 1em;
height: 1em;
border-radius: 0.5em;
transform: translate(-50%, -50%);
}
.loader:before {
animation: slackbefore 2s infinite;
}
.loader:after {
animation: slackafter 2s infinite;
}
@keyframes slackbefore {
0% {
width: 1em;
box-shadow: 2em -1em rgba(225, 20, 98, 0.75), -2em 1em rgba(111, 202, 220, 0.75);
}
35% {
width: 5em;
box-shadow: 0 -1em rgba(225, 20, 98, 0.75), 0 1em rgba(111, 202, 220, 0.75);
}
70% {
width: 1em;
box-shadow: -2em -1em rgba(225, 20, 98, 0.75), 2em 1em rgba(111, 202, 220, 0.75);
}
100% {
box-shadow: 2em -1em rgba(225, 20, 98, 0.75), -2em 1em rgba(111, 202, 220, 0.75);
}
}
@keyframes slackafter {
0% {
height: 1em;
box-shadow: 1em 2em rgba(61, 184, 143, 0.75), -1em -2em rgba(233, 169, 32, 0.75);
}
35% {
height: 5em;
box-shadow: 1em 0 rgba(61, 184, 143, 0.75), -1em 0 rgba(233, 169, 32, 0.75);
}
70% {
height: 1em;
box-shadow: 1em -2em rgba(61, 184, 143, 0.75), -1em 2em rgba(233, 169, 32, 0.75);
}
100% {
box-shadow: 1em 2em rgba(61, 184, 143, 0.75), -1em -2em rgba(233, 169, 32, 0.75);
}
}
/* position to center */
.loader {
position: absolute;
top: calc(50% - 2.5em);
left: calc(50% - 2.5em);
}
/**
* disable background
*/
.loader-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
display: table;
transition: opacity .3s ease;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table border="1">
<form method="post">
<tr>
<td colspan="5" align="right">
<input type="button" class="submit btn btn-success farmlead-green fl-btn-submit" value="Submit" />
</td>
</tr>
</form>
</table>
あなたはGIF画像を表示した後JSのトンを実行していますか? JSはGIFアニメーションをブロックするためです。 – mpen
はい、show gifの後、再帰的メソッドを呼び出します。 – sergioBertolazzo
'setTimeout(()recursive(x、y、z)、0)'のような再帰関数を呼び出してください。 0msの遅延は、UIに再レンダリングの機会を与えるでしょう。 – mpen