Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

HTML-CSS: Bouncing loader

HTML-CSS : Exercise-13 with Solution

Using HTML, CSS create a bouncing loader animation.

  • Use @keyframes to define a bouncing animation, using the opacity and transform properties. Use a single axis translation on transform: translate3d() to achieve better animation performance.
  • Create a parent container, .bouncing-loader, for the bouncing circles. Use display: flex and justify-content: center to position them in the center.
  • Give the three bouncing circle <div> elements the same width and height and border-radius: 50% to make them circular.
  • Apply the bouncing-loader animation to each of the three bouncing circles.
  • Use a different animation-delay for each circle and animation-direction: alternate to create the appropriate effect.

HTML Code:

<!--License: https://bit.ly/3GjrtVF-->
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Using HTML, CSS create a bouncing loader animation</title>
</head>
<body>
  <strong>Preview:</strong><br>
<div class="bouncing-loader">
  <div> w</div>
  <div> 3</div>
  <div> r</div>
  <div> e</div>
  <div> s</div>
  <div> o</div>
  <div> u</div>
  <div> r</div>
  <div> c</div>
  <div> e</div>
  </div>
</body>
</html>

CSS Code:

 
@keyframes bouncing-loader {
  to {
    opacity: 0.1;
    transform: translate3d(0, -16px, 0);
  }
}

.bouncing-loader {
  display: flex;
  justify-content: center;
 }

.bouncing-loader > div {
  width: 16px;
  height: 16px;
  margin: 3rem 0.2rem;
  background: #8385aa;
  border-radius: 50%;
  text: center;
  animation: bouncing-loader 0.6s infinite alternate;
}

.bouncing-loader > div:nth-child(2) {
  animation-delay: 0.2s;
}

.bouncing-loader > div:nth-child(3) {
  animation-delay: 0.4s;
}
.bouncing-loader > div:nth-child(4) {
  animation-delay: 0.6s;
}
.bouncing-loader > div:nth-child(5) {
  animation-delay: 0.8s;
}
.bouncing-loader > div:nth-child(6) {
  animation-delay: 0.10s;
}
.bouncing-loader > div:nth-child(7) {
  animation-delay: 0.2s;
}
.bouncing-loader > div:nth-child(8) {
  animation-delay: 0.4s;
}
.bouncing-loader > div:nth-child(9) {
  animation-delay: 0.5s;
}

HTML-CSS Editor:

See the Pen html-css-practical-exercises by w3resource (@w3resource) on CodePen.


What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



HTML-CSS: Tips of the Day

What is the difference between id and class in CSS, and when should I use them?

Example:

<div id="header_id" class="header_class">
Text
</div>
#header_id {font-color:#fff}
.header_class {font-color:#000}

(Note that CSS uses the prefix # for IDs and . for Classes.)

However color was an HTML 4.01 <font> tag attribute deprecated in HTML 5. In CSS there is no "font-color", the style is color so the above should read:

Example:

<div id="header_id" class="header_class">
Text
</div>
#header_id {color:#fff}
.header_class {color:#000} 

The text would be white.

Ref: https://bit.ly/39Stv4P