Hi @Donald Symmons,
I tried to do this on page load, in order to set a time frame when the animated check icon will display. But I can't seem to get it done. Please any help?
Every code you write on the server side will run before the browser renders the page.
You'd better implement this on the client side, perhaps using a Javascript method.
You can refer to the following code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
document.getElementById('checkicon').style.display = 'block';
setTimeout(function () {
document.getElementById('label').style.animation = 'none';
document.getElementById('label').style.borderColor = "#5cb85c";
document.getElementById('label').style.transition = "border 0.5s ease-out";
}, 5000);
});
</script>
All Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body{
padding: 3em;
text-align: center;
}
h1{
margin: 1em;
}
#label{
position: relative;
height: 125px;
width: 125px;
display: inline-block;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 50%;
border-left-color: #5cb85c;
animation: rotate 1.2s linear infinite;
}
@keyframes rotate {
50%{
border-left-color: #9b59b6;
}
75%{
border-left-color: #e67e22;
}
100%{
transform: rotate(360deg);
}
}
#label .check-icon{
display: none;
}
#label .check-icon:after{
position: absolute;
content: "";
top: 50%;
left: 28px;
transform: scaleX(-1) rotate(135deg);
height: 56px;
width: 28px;
border-top: 4px solid #5cb85c;
border-right: 4px solid #5cb85c;
transform-origin: left top;
animation: check-icon 0.8s ease;
}
@keyframes check-icon {
0%{
height: 0;
width: 0;
opacity: 1;
}
20%{
height: 0;
width: 28px;
opacity: 1;
}
100%{
height: 56px;
width: 28px;
opacity: 1;
}
}
/* input:checked ~ #label .check-icon{
display: block;
}
input:checked ~ #label{
animation: none;
border-color: #5cb85c;
transition: border 0.5s ease-out;
}*/
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
document.getElementById('checkicon').style.display = 'block';
setTimeout(function () {
document.getElementById('label').style.animation = 'none';
document.getElementById('label').style.borderColor = "#5cb85c";
document.getElementById('label').style.transition = "border 0.5s ease-out";
}, 5000);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Loader with Check</h1>
<%-- <input type="checkbox" runat="server" id="check" />--%>
<div for="" runat="server" class="loading" id="label">
<div class="check-icon" runat="server" id="checkicon"></div>
</div>
</div>
</form>
</body>
</html>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.