Creating a loading screen with CSS and aiming for realistic behavior can be a challenge. Utilizing the
animation-timing-function: cubic-bezier(1, 0, 1, 1)
property gives a decent result, but perfecting it requires understanding how the parameters in cubic-bezier
function truly work. Experimenting with different values on sites like this can help achieve desired effects.
In summary, achieving physically accurate behavior in animations can be challenging. While a CSS-only solution is preferred, incorporating JavaScript is also an option if necessary.
Below is an example:
body{
background-color: #02a2bb;
}
.wrapper {
padding: 50px;
text-align: center;
}
.content {
height: 125px;
margin: 0 auto;
position: relative;
display: inline-block;
}
.ball {
width: 25px;
height: 25px;
display: inline-block;
border-radius: 50%;
bottom: 0;
position: relative;
background-color: #fff;
z-index: 1;
}
.ball-shadow {
width: 20px;
height: 6px;
border-radius: 50%;
position: absolute;
bottom: 9px;
left: 50%;
-webkit-transform: translateX(-50%);
-moz-transform: translateX(-50%);
transform: translateX(-50%);
}
.animated {
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
-ms-animation-duration: 1s;
-o-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-ms-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-ms-animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.animated.jump, .animated.displace, .animated.diffuse-scale {
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
-ms-animation-duration: 3s;
-o-animation-duration: 3s;
animation-duration: 3s;
}
... (Code continues)
</div>
Suggestion
Consider using a preprocessor like Less or SCSS to define physical variables and characteristics in your animations. These tools allow for easier manipulation of values and simulation of realistic behaviors through mixins or functions. It simplifies the process and keeps the solution purely CSS-based.