diff --git a/Animated-loading-animation.md b/Animated-loading-animation.md deleted file mode 100644 index 6481d0105..000000000 --- a/Animated-loading-animation.md +++ /dev/null @@ -1,110 +0,0 @@ -### Bouncy Animated loading animation - -Clean & simple animated loading animation with CSS3. If you are worried about super deep browser support, use a GIF. - -#### HTML - -```html -
- - - -
-``` - -#### CSS - -```css -.snippet-demo__Animated-loading-animation { - text-align: center; -} -.snippet-demo__Animated-loading-animation span { - display: inline-block; - vertical-align: middle; - width: 24px; - height: 24px; - margin: 50px auto; - background: black; - border-radius: 50px; - animation: loader 0.9s infinite alternate; -} -.snippet-demo__Animated-loading-animation span:nth-of-type(2) { - animation-delay: 0.3s; -} -.snippet-demo__Animated-loading-animation span:nth-of-type(3) { - animation-delay: 0.6s; -} -@keyframes loader { - 0% { - opacity: 0.9; - transform: translateY(0); - } - 100% { - opacity: 0.1; - transform: translateY(-21px); - } -} -``` - -#### Demo - - - -
-
- - - -
-
- - - - - -#### Explanation - - -+1. `translateY` The translateY() CSS function repositions an element vertically on the 2D plane. -+2. `animation` The animation CSS property is a shorthand property for the various animation properties: animation-name, animation-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, animation-fill-mode, and animation-play-state. - -#### Browser support - - - -94.7% - - - -* https://caniuse.com/#feat=css-animation \ No newline at end of file diff --git a/bouncing-loader.md b/bouncing-loader.md new file mode 100644 index 000000000..105167cc0 --- /dev/null +++ b/bouncing-loader.md @@ -0,0 +1,113 @@ +### Bouncing loader + +Creates a bouncing loader animation. + +#### HTML + +```html +
+
+
+
+
+``` + +#### CSS + +```css +@keyframes bouncing-loader { + from { + opacity: 1; + transform: translateY(0); + } + to { + opacity: 0.1; + transform: translateY(-1rem); + } +} +.bouncing-loader { + display: flex; + justify-content: center; +} +.bouncing-loader > div { + width: 1rem; + height: 1rem; + margin: 3rem 0.2rem; + background: #8385aa; + border-radius: 50%; + animation: bouncing-loader 0.6s infinite alternate; +} +.bouncing-loader > div:nth-of-type(2) { + animation-delay: 0.2s; +} +.bouncing-loader > div:nth-of-type(3) { + animation-delay: 0.4s; +} +``` + +#### Demo + +
+
+
+
+
+
+
+ + + +#### Explanation + +Note: `1rem` is usually `16px`. + +1. `@keyframes` defines an animation that has two states, where the element changes `opacity`, and is translated up on the 2D plane using `transform: translateY()`. + +2. `.bouncing-loader` is the parent container of the bouncing circles and uses `display: flex` + and `justify-content: center` to position them in the in the center. + +3. Using `.bouncing-loader > div`, we target the three child `div`s of the parent to be styled. The `div`s are given a width and height of `1rem`, using `border-radius: 50%` to turn them from squares to circles. + +4. `margin: 3rem 0.2rem` specifies that each circle has a top/bottom margin of `3rem` and left/right margin + of `0.2rem` so that they do not directly touch each other, giving them some breathing room. + +5. `animation` is a shorthand property for the various animation properties: `animation-name`, `animation-duration`, `animation-iteration-count`, `animation-direction` are used. + +6. `animation-delay` is used on the second and third `div` respectively, so that each element does not start the animation at the same time. + +#### Browser support + +✅ No caveats. + +* https://caniuse.com/#feat=css-animation + +