Advertisement
ESDalwampo

CSS Tricks 11 - Ball on Stair

Feb 27th, 2023 (edited)
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.69 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.   <style>
  6.     * {
  7.       margin: 0;
  8.       padding: 0;
  9.     }
  10.    
  11.     html {
  12.       height: 100%;
  13.     }
  14.  
  15.     body {
  16.       height: 100%;
  17.       background: #3d3d3d;
  18.       display: flex;
  19.       align-items: center;
  20.       justify-content: center;
  21.     }
  22.  
  23.     .loader {
  24.       position: relative;
  25.       width: 75px;
  26.       height: 100px;
  27.     }
  28.    
  29.     .ball {
  30.       position: absolute;
  31.       bottom: 10px;
  32.       left: 0;
  33.       width: 10px;
  34.       height: 10px;
  35.       background: #fff;
  36.       border-radius: 50%;
  37.       animation: ball 4s infinite;
  38.     }
  39.  
  40.     .stair {
  41.       position: absolute;
  42.       bottom: 0;
  43.       width: 10px;
  44.       height: 50%;
  45.       background: #fff;
  46.       transform-origin: center bottom;
  47.       box-shadow: 1px 1px 0 rgba(0, 0, 0, .2);
  48.     }
  49.  
  50.     .stair:nth-child(1) {
  51.       left: 0px;
  52.       transform: scale(1, 0.2);
  53.       animation: bar-up-1 4s infinite;
  54.     }
  55.  
  56.     .stair:nth-child(2) {
  57.       left: 15px;
  58.       transform: scale(1, 0.4);
  59.       animation: bar-up-2 4s infinite;
  60.     }
  61.  
  62.     .stair:nth-child(3) {
  63.       left: 30px;
  64.       transform: scale(1, 0.6);
  65.       animation: bar-up-3 4s infinite;
  66.     }
  67.  
  68.     .stair:nth-child(4) {
  69.       left: 45px;
  70.       transform: scale(1, 0.8);
  71.       animation: bar-up-4 4s infinite;
  72.     }
  73.  
  74.     .stair:nth-child(5) {
  75.       left: 60px;
  76.       transform: scale(1, 1);
  77.       animation: bar-up-5 4s infinite;
  78.     }
  79.  
  80.  
  81.     @keyframes ball {
  82.       0% { transform: translate(0, 0); }
  83.       5% { transform: translate(8px, -14px); }
  84.       10% { transform: translate(15px, -10px); }
  85.       17% { transform: translate(23px, -24px);}
  86.       20% { transform: translate(30px, -20px); }
  87.       27% { transform: translate(38px, -34px); }
  88.       30% { transform: translate(45px, -30px); }
  89.       37% { transform: translate(53px, -44px); }
  90.       40% { transform: translate(60px, -40px); }
  91.       50% { transform: translate(60px, 0); }
  92.       57% { transform: translate(53px, -14px); }
  93.       60% { transform: translate(45px, -10px); }
  94.       67% { transform: translate(37px, -24px); }
  95.       70% { transform: translate(30px, -20px); }
  96.       77% { transform: translate(22px, -34px); }
  97.       80% { transform: translate(15px, -30px); }
  98.       87% { transform: translate(7px, -44px); }
  99.       90% { transform: translate(0, -40px); }
  100.       100% { transform: translate(0, 0); }
  101.     }
  102.  
  103.     @keyframes bar-up-1 {
  104.       0% { transform: scale(1, 0.2); }
  105.       40% { transform: scale(1, 0.2); }
  106.       50% { transform: scale(1, 1); }
  107.       90% { transform: scale(1, 1); }
  108.       100% { transform: scale(1, 0.2); }
  109.     }
  110.  
  111.     @keyframes bar-up-2 {
  112.       0% { transform: scale(1, 0.4); }
  113.       40% { transform: scale(1, 0.4); }
  114.       50% { transform: scale(1, 0.8); }
  115.       90% { transform: scale(1, 0.8); }
  116.       100% { transform: scale(1, 0.4); }
  117.     }
  118.  
  119.     @keyframes bar-up-3 {
  120.       0% { transform: scale(1, 0.6); }
  121.       100% { transform: scale(1, 0.6); }
  122.     }
  123.  
  124.     @keyframes bar-up-4 {
  125.       0% { transform: scale(1, 0.8); }
  126.       40% { transform: scale(1, 0.8); }
  127.       50% { transform: scale(1, 0.4); }
  128.       90% { transform: scale(1, 0.4); }
  129.       100% { transform: scale(1, 0.8); }
  130.     }
  131.  
  132.     @keyframes bar-up-5 {
  133.       0% { transform: scale(1, 1); }
  134.       40% { transform: scale(1, 1); }
  135.       50% { transform: scale(1, 0.2); }
  136.       90% { transform: scale(1, 0.2); }
  137.       100% { transform: scale(1, 1); }
  138.     }
  139.   </style>
  140. </head>
  141.  
  142. <body>
  143.   <div class="loader">
  144.     <div class="stair"></div>
  145.     <div class="stair"></div>
  146.     <div class="stair"></div>
  147.     <div class="stair"></div>
  148.     <div class="stair"></div>
  149.     <div class="ball"></div>
  150.   </div>
  151. </body>
  152.  
  153. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement