Problem with running animation in CSS

0

I did an animation in CSS, but it stopped working. Where is the error?

HTML / CSS

#loading {
	background-color: #0e5077;
	height: 100%;
	width: 100%;
	position: fixed;
	z-index: 99;
	margin-top: 0px;
	top: 0px;
}

#loading-center {
	width: 100%;
	height: 100%;
	position: relative;
}
#loading-center-absolute {
	position: absolute;
	left: 50%;
	top: 50%;
	height: 100px;
	width: 100px;
	margin-top: -50px;
	margin-left: -50px;
	-ms-transform: rotate(-135deg);
	-webkit-transform: rotate(-135deg);
	transform: rotate(-135deg);
}
#object_one {
	left: 55px;
	top: 55px;
	width: 10px;
	height: 10px;
}
#object_two {
	left: 45px;
	top: 45px;
	width: 30px;
	height: 30px;
	-webkit-animation-delay: 0.2s;
	animation-delay: 0.2s;
}
#object_three {
	left: 35px;
	top: 35px;
	width: 50px;
	height: 50px;
	-webkit-animation-delay: 0.4s;
	animation-delay: 0.4s;
}
#object_four {
	left: 25px;
	top: 25px;
	width: 70px;
	height: 70px;
	-webkit-animation-delay: 0.6s;
	animation-delay: 0.6s;
}
.object {
	-moz-border-radius: 50% 50% 50% 50%;
	-webkit-border-radius: 50% 50% 50% 50%;
	border-radius: 50% 50% 50% 50%;
	position: absolute;
	border-top: 2px solid #FFF;
	border-bottom: 2px solid transparent;
	border-left: 2px solid #FFF;
	border-right: 2px solid transparent;
	-webkit-animation: animate 2s infinite;
	animation: animate 2s infinite;
}
<div id="loading">
	<div id="loading-center-absolute">
                <div class="object" id="object_one"></div>
                <div class="object" id="object_two"></div>
                <div class="object" id="object_three"></div>
                <div class="object" id="object_four"></div>
            </div>
</div>
    
asked by anonymous 22.08.2018 / 20:11

2 answers

0

I think you forgot to add the "@keyframes" rule to run your animation, as I did below. For linear execution, with no pauses between start and end of the animation, add "linear" to the "animation" property.

#loading {
	background-color: #0e5077;
	height: 100%;
	width: 100%;
	position: fixed;
	z-index: 99;
	margin-top: 0px;
	top: 0px;
}

#loading-center {
	width: 100%;
	height: 100%;
	position: relative;
}
#loading-center-absolute {
	position: absolute;
	left: 50%;
	top: 50%;
	height: 100px;
	width: 100px;
	margin-top: -50px;
	margin-left: -50px;
	-ms-transform: rotate(-135deg);
	-webkit-transform: rotate(-135deg);
	transform: rotate(-135deg);
}
#object_one {
	left: 55px;
	top: 55px;
	width: 10px;
	height: 10px;
}
#object_two {
	left: 45px;
	top: 45px;
	width: 30px;
	height: 30px;
	-webkit-animation-delay: 0.2s;
	animation-delay: 0.2s;
}
#object_three {
	left: 35px;
	top: 35px;
	width: 50px;
	height: 50px;
	-webkit-animation-delay: 0.4s;
	animation-delay: 0.4s;
}
#object_four {
	left: 25px;
	top: 25px;
	width: 70px;
	height: 70px;
	-webkit-animation-delay: 0.6s;
	animation-delay: 0.6s;
}
.object {
	-moz-border-radius: 50% 50% 50% 50%;
	-webkit-border-radius: 50% 50% 50% 50%;
	border-radius: 50% 50% 50% 50%;
	position: absolute;
	border-top: 2px solid #FFF;
	border-bottom: 2px solid transparent;
	border-left: 2px solid #FFF;
	border-right: 2px solid transparent;
	-webkit-animation: animate 2s linear infinite;
	animation: animate 2s linear infinite;
}

@keyframes animate {
	from {
	    transform: rotate(0deg)
	}
	to {
	    transform: rotate(360deg)
	}
}
<div id="loading">
	<div id="loading-center-absolute">
                <div class="object" id="object_one"></div>
                <div class="object" id="object_two"></div>
                <div class="object" id="object_three"></div>
                <div class="object" id="object_four"></div>
            </div>
</div>
    
22.08.2018 / 20:24
0

#loading {
	background-color: #0e5077;
	height: 100%;
	width: 100%;
	position: fixed;
	z-index: 99;
	margin-top: 0px;
	top: 0px;
}

#loading-center {
	width: 100%;
	height: 100%;
	position: relative;
}
#loading-center-absolute {
	position: absolute;
	left: 50%;
	top: 50%;
	height: 100px;
	width: 100px;
	margin-top: -50px;
	margin-left: -50px;
	-ms-transform: rotate(-135deg);
	-webkit-transform: rotate(-135deg);
	transform: rotate(-135deg);
}
#object_one {
	left: 55px;
	top: 55px;
	width: 10px;
	height: 10px;
}
#object_two {
	left: 45px;
	top: 45px;
	width: 30px;
	height: 30px;
	-webkit-animation-delay: 0.2s;
	animation-delay: 0.2s;
}
#object_three {
	left: 35px;
	top: 35px;
	width: 50px;
	height: 50px;
	-webkit-animation-delay: 0.4s;
	animation-delay: 0.4s;
}
#object_four {
	left: 25px;
	top: 25px;
	width: 70px;
	height: 70px;
	-webkit-animation-delay: 0.6s;
	animation-delay: 0.6s;
}
.object {
	-moz-border-radius: 50% 50% 50% 50%;
	-webkit-border-radius: 50% 50% 50% 50%;
	border-radius: 50% 50% 50% 50%;
	position: absolute;
	border-top: 2px solid #FFF;
	border-bottom: 2px solid transparent;
	border-left: 2px solid #FFF;
	border-right: 2px solid transparent;
	-webkit-animation: rotation 2s infinite linear;
	animation: rotation 2s infinite linear;
}

@-webkit-keyframes rotation {
		from {
				-webkit-transform: rotate(0deg);
		}
		to {
				-webkit-transform: rotate(359deg);
		}
}
<div id="loading">
	<div id="loading-center-absolute">
                <div class="object" id="object_one"></div>
                <div class="object" id="object_two"></div>
                <div class="object" id="object_three"></div>
                <div class="object" id="object_four"></div>
            </div>
</div>
    
22.08.2018 / 20:31