Connect with us!
Juggling Ball Loader animation HTML and CSS tutorial for beginners 2021 #shorts #coding
Juggling is an actual ability, performed by a performer, including the control of articles for amusement, diversion, craftsmanship or game. In this article lets see how to create one using HTML and CSS.
Table of Contents
Juggling Ball CSS Properties
Following are the CSS properties used:
Border-radius: The border-radius CSS property rounds the corners of an element’s outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.
Width: The width CSS property sets an element’s width. By default, it sets the width of the content area, but if box-sizing is set to border-box, it sets the width of the border area.
Inset: The inset CSS property is a shorthand that corresponds to the top, right, bottom, and/or left properties. It has the same multi-value syntax of the margin shorthand.
Background: The background shorthand CSS property sets all background style properties at once, such as color, image, origin and size, or repeat method.
Top: The top CSS property participates in specifying the vertical position of a positioned element. It has no effect on non-positioned elements.
Left: The left CSS property participates in specifying the horizontal position of a positioned element. It has no effect on non-positioned elements.
Box-shadow: The box-shadow CSS property adds shadow effects around an element’s frame. You can set multiple effects separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread radius, and color.
Transform: The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.
Content: The content CSS property replaces an element with a generated value. Objects inserted using the content property are anonymous replaced elements.
Position: The position CSS property sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final location of positioned elements.
Height: The height CSS property specifies the height of an element. By default, the property defines the height of the content area. If box-sizing is set to border-box, however, it instead determines the height of the border area.
Juggling Ball Code Block
Here is the code for implementing the Juggling Ball Loader Animation.
.juggle-ball {
top: 40px;
left: 40px;
width: 20px;
height: 20px;
position: relative;
}
.juggle-ball::before,
.juggle-ball::after {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
background: #f03355;
}
.juggle-ball::before {
box-shadow: -40px 0 #ff6d00;
}
.juggle-ball::after {
transform: rotate(0deg) translateX(40px);
}
Yay! We have created the static Juggling Ball Loader Animation.
Here is the output:
Juggling Ball CSS Animation
juggle-ani-1 , juggle-ani-2 animation can be implemented by scaling up and down the shape linearly.
Following are the classes used for animation.
The @keyframes CSS at-rule controls the intermediate steps in a CSS animation sequence by defining styles for keyframes (or waypoints) along the animation sequence. This gives more control over the intermediate steps of the animation sequence than transitions.
The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.
Here is the CSS animation class implementing CSS.
@keyframes juggle-ani-1 {
100% {
transform: translateX(40px);
}
}
@keyframes juggle-ani-2 {
100% {
transform: rotate(-180deg) translateX(40px);
}
}
The following way is to declare the CSS Class inside the class block.
.juggle-ball {
top: 40px;
left: 40px;
width: 20px;
height: 20px;
position: relative;
}
.juggle-ball::before,
.juggle-ball::after {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
background: #f03355;
}
.juggle-ball::before {
box-shadow: -40px 0 #ff6d00;
animation: juggle-ani-1 1s infinite linear;
}
.juggle-ball::after {
transform: rotate(0deg) translateX(40px);
animation: juggle-ani-2 1s infinite linear;
}
@keyframes juggle-ani-1 {
100% {
transform: translateX(40px);
}
}
@keyframes juggle-ani-2 {
100% {
transform: rotate(-180deg) translateX(40px);
}
}
Following is the output for Juggling Ball Loader Animation animation.
Juggling Ball Video Tutorial
You can find the complete coding tutorial in the following YouTube Short video.
Complete Code using HTML and CSS
Copy and paste the complete code in Visual studio code to view the output.
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.juggle-ball {
top: 40px;
left: 40px;
width: 20px;
height: 20px;
position: relative;
}
.juggle-ball::before,
.juggle-ball::after {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
background: #f03355;
}
.juggle-ball::before {
box-shadow: -40px 0 #ff6d00;
animation: juggle-ani-1 1s infinite linear;
}
.juggle-ball::after {
transform: rotate(0deg) translateX(40px);
animation: juggle-ani-2 1s infinite linear;
}
@keyframes juggle-ani-1 {
100% {
transform: translateX(40px);
}
}
@keyframes juggle-ani-2 {
100% {
transform: rotate(-180deg) translateX(40px);
}
}
</style>
<title>Salow Studios</title>
</head>
<body>
<h1>Juggling Ball Loader Animation</h1>
<div class="juggle-ball"></div>
</body>
</html>
Thank you for reading this article. I hope that it helps you creating your own Juggling Ball Loader Animation Animation using CSS and HTML. See you in next tutorial!