I'm making a loading screen for my website and i want to make a line that goes from 0-100% in few sec. I have made it successfully, but when I try adding animation-delay nothing happens. I want the animation to start 2 sec after the website loads. Anyone can help?
Here is the code:
.loading
{
position: fixed;
top: 50%;
left: 50%;
height: 10px;
display: flex;
transform: translate(-70px);
animation-delay: 2s;
}
.obj
{
width: 0px;
height: 8px;
background: black;
border-radius: 15px;
z-index: 1; position:relative;
animation:loading 2s;
animation-fill-mode: forwards;
animation-delay: 2s;
}
@keyframes loading{
0% {
width: 0px;
}
100% {
width: 150px;
}
}
<head>
<link rel="stylesheet" type="text/css" href="loadingstyles.css">
</head>
<body>
<div class="loading">
<div class="obj"></div>
</div>
</body>