Balancing ball on the stick animation using only CSS
Swinging ball balance on a bat is a basic CSS animation where the bat will move slightly back and forth direction in order to move the ball that will rotate in to-&-fro motion over the bat in an infinite loop. In this article, we will see how to create the swinging ball balance on bat animation using HTML & CSS.
Approach: The following approach will be utilized to create the swinging ball balance on bat animation, which is described below:
- Create the bat element and ball as the child element of the bat.
- We styled the body element with a black background and centered the elements.
- The ball is styled with a position relative to the inner detail dot. We have kept the background of the ball as red, also, added the animation for an infinite time period, and with a smooth ease-in-out effect.
- The ball::after is the pseudo-element maker for detailing the ball as it should not look like a solid circle that is moving in linear motion.
- We have added the animation of balancing the ball with a smooth ease-in-out effect for an infinite time period.
- Create the keyframes for timing the animation making the bat rotate 15 degree negative to 15 degree positive. And the ball with the calc function and rotate it to 360 degree from 0.
Example: This example illustrates the swinging ball balance on bat animation using CSS.
My Personal Notes arrow_drop_up
Please Login to comment...