Animate child div after parent div has completed animation - css

I have 2 div ("a" and "b") I'm trying when div "a" slide Up and stop, div "b"
slide Up inside div "a".
<div id="a" class="animated slideInUp">
<div id="b" class="animated slideInUp"> </div>
</div>
Here is my JSFiddle
#a {
width: 100px;
height: 50px;
background-color: #000;
border-radius: 10px;
margin: 0 auto;
position: relative;
}
#b {
width: 100%;
height: 10px;
background-color: #860169;
position: absolute;
bottom: 0;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animated.infinite {
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.animated.hinge {
-webkit-animation-duration: 2s;
animation-duration: 2s;
}
.animated.bounceIn,
.animated.bounceOut {
-webkit-animation-duration: .75s;
animation-duration: .75s;
}
.animated.flipOutX,
.animated.flipOutY {
-webkit-animation-duration: .75s;
animation-duration: .75s;
}
#-webkit-keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 10%, 0);
transform: translate3d(0, 10%, 0);
}
}
#keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 10%, 0);
transform: translate3d(0, 10%, 0);
}
}
.slideInUp {
-webkit-animation-name: slideInUp;
animation-name: slideInUp;
}
<div id="a" class="animated slideInUp">
<div id="b" class="animated slideInUpChild"> </div>
</div>

translate3d(0, y%, 0) will only translate the element in Y-axis by y% the height of the element. That is 100% would translate it by 10px (height of the child) and 10% would translate it by 1px. In addition you are positioning the element at the bottom of the parent and hence translating it by 1px (end state) is not going to have any visual effect.
You need to do the following changes to achieve the effect that you are looking for:
Use a different animation for the child element, which will move the element from bottom: 0px to bottom: calc(100% - 10px) (the minus 10px is for the height of the element). The first keyframe at bottom: 0px positions the element at the bottom of the container and then gradually move it to the top of the parent element.
Add an animation-delay to the child element that is equal to the animation-duration of parent element. This is required to make sure that the child element does not start animation before the parent element has reached the top.
Note that since you have border-radius set the to the child for the bottom-left and bottom-right, the element won't look nice once it has reached the top.
#a {
width: 100px;
height: 50px;
background-color: #000;
border-radius: 10px;
margin: 0 auto;
position: relative;
}
#b {
width: 100%;
height: 10px;
background-color: #860169;
position: absolute;
bottom: 0;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animated.infinite {
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.animated.hinge {
-webkit-animation-duration: 2s;
animation-duration: 2s;
}
.animated.bounceIn,
.animated.bounceOut {
-webkit-animation-duration: .75s;
animation-duration: .75s;
}
.animated.flipOutX,
.animated.flipOutY {
-webkit-animation-duration: .75s;
animation-duration: .75s;
}
#-webkit-keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 10%, 0);
transform: translate3d(0, 10%, 0);
}
}
#keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 10%, 0);
transform: translate3d(0, 10%, 0);
}
}
.slideInUp {
-webkit-animation-name: slideInUp;
animation-name: slideInUp;
-webkit-animation-duration: 1s;
animation-duration: 1s;
}
.slideInUpChild {
-webkit-animation-name: slideInUpChild;
animation-name: slideInUpChild;
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
#-webkit-keyframes slideInUpChild {
from {
bottom: 0;
}
to {
bottom: calc(100% - 10px);
}
}
#keyframes slideInUpChild {
from {
bottom: 0;
}
to {
bottom: calc(100% - 10px);
}
}
<div id="a" class="animated slideInUp">
<div id="b" class="animated slideInUpChild"> </div>
</div>
One simple way to overcome the border-radius problem that I have mentioned above would be to do away with the border-radius and let the overflow: hidden setting on the parent take care of it.
#a {
width: 100px;
height: 50px;
background-color: #000;
border-radius: 10px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
#b {
width: 100%;
height: 10px;
background-color: #860169;
position: absolute;
bottom: 0;
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animated.infinite {
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.animated.hinge {
-webkit-animation-duration: 2s;
animation-duration: 2s;
}
.animated.bounceIn,
.animated.bounceOut {
-webkit-animation-duration: .75s;
animation-duration: .75s;
}
.animated.flipOutX,
.animated.flipOutY {
-webkit-animation-duration: .75s;
animation-duration: .75s;
}
#-webkit-keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 10%, 0);
transform: translate3d(0, 10%, 0);
}
}
#keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 10%, 0);
transform: translate3d(0, 10%, 0);
}
}
.slideInUp {
-webkit-animation-name: slideInUp;
animation-name: slideInUp;
-webkit-animation-duration: 1s;
animation-duration: 1s;
}
.slideInUpChild {
-webkit-animation-name: slideInUpChild;
animation-name: slideInUpChild;
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
#-webkit-keyframes slideInUpChild {
from {
bottom: 0;
}
to {
bottom: calc(100% - 10px);
}
}
#keyframes slideInUpChild {
from {
bottom: 0;
}
to {
bottom: calc(100% - 10px);
}
}
<div id="a" class="animated slideInUp">
<div id="b" class="animated slideInUpChild"> </div>
</div>

Related

CSS animation not working only on Safari latest version

I am trying to find the compatibility issue with Safari to no avail in a CSS glitch text animation, all keyframes are on and the animation is specified with each property, i cut the middle keyframes to make it simpler:
.glitch {
animation-name: glitch-skew;
animation-duration: 1s;
animation-direction: alternate-reverse;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 0s;
}
.glitch::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
left: 3px;
text-shadow: -3px 0 #ff00c1;
animation-name: glitch-anim;
animation-duration: 6s;
animation-direction: alternate-reverse;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 0s;
}
.glitch::after {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
left: -3px;
text-shadow: -3px 0 #00fff9, 3px 3px #ff00c1;
animation-name: glitch-anim2;
animation-duration: 1.5s;
animation-iteration-count: infinite;
animation-direction: alternate-reverse;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 0s;
}
#keyframes glitch-anim {
0% {
clip: rect(79px, 9999px, 90px, 0);
transform: skew(0.57deg);
}
5% {
clip: rect(4px, 9999px, 59px, 0);
transform: skew(0.73deg);
}
100% {
clip: rect(40px, 9999px, 94px, 0);
transform: skew(0.6deg);
}
}
#keyframes glitch-anim2 {
0% {
clip: rect(96px, 9999px, 50px, 0);
transform: skew(0.7deg);
}
5% {
clip: rect(81px, 9999px, 66px, 0);
transform: skew(0.38deg);
}
100% {
clip: rect(96px, 9999px, 10px, 0);
transform: skew(0.08deg);
}
}
#keyframes glitch-skew {
0% {
transform: skew(0deg);
}
100% {
transform: skew(0deg);
}
}
Any ideas on what could be the issue here? Or maybe there is a way to hide this animation only on safari devices? I know its a long shot
Thank you
try using the -webkit prefix for the animation elements (such as -webkit-animation-duration, -webkit-animation-name, etc.), since safari is a webkit browser, targeting the css styles to its framework should have an impact.

CSS animation 'origin' for each <g>

Using CSS animation, I am adding a 'wobble' effect to each letter in a word. Each letter is made up of an SVG group <g>. However, as you can see in the example, the effect gets more extreme with each letter, whereas I want a consistent 'wobble' per letter (the same effect on each letter). How can this be acheived?
Note: I have not included the SVG source code, to keep the question tidy. It can be seen in the example if needed.
Thanks.
SCSS
// Logo
.logo {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 1;
width: 260px;
display: block;
// SVG
svg {
display: block;
width: 100%;
overflow: visible;
g {
fill: transparent;
transition: all 300ms ease-in-out;
#keyframes wobble {
0% { transform: rotate(0) translate3d(0, 0, 0) }
25% { transform: rotate(2deg) translate3d(1px, 0, 0) }
50% { transform: rotate(-1deg) translate3d(0, -1px, 0) }
75% { transform: rotate(1deg) translate3d(-1px, 0, 0) }
100% { transform: rotate(-2deg) translate3d(-1px, -1px, 0) }
}
animation-duration: 400ms;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-name: wobble;
animation-timing-function: ease-in-out;
path {
fill: red;
}
}
}
}
Example
I could not figure out how to do it with SVGs - I did manage to come up with something similar to your requirement.
Part of the solution involved using a center point for the rotation:
transform-origin: center;
See demo below
#my-logo div {
display: inline-block;
color: red;
font-size: 60px;
font-family: arial;
font-weight: bolder;
text-transform: uppercase;
fill: transparent;
transition: all 300ms ease-in-out;
transform-origin: center;
animation-duration: 400ms;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-name: wobble;
animation-timing-function: ease-in-out;
}
#keyframes wobble {
0% {
transform: rotate(0) translate3d(0, 0, 0);
}
25% {
transform: rotate(2deg) translate3d(1px, 0, 0);
}
50% {
transform: rotate(-1deg) translate3d(0, -1px, 0);
}
75% {
transform: rotate(1deg) translate3d(-1px, 0, 0);
}
100% {
transform: rotate(-2deg) translate3d(-1px, -1px, 0);
}
}
<div id="my-logo">
<div>o</div>
<div>u</div>
<div>t</div>
<div>r</div>
<div>a</div>
<div>g</div>
<div>e</div>
<div>
<!-- also works with images -->
<img src="http://placekitten.com/100/100" />
</div>
</div>

CSS animation doesn't work as expected

I have this code: jsfiddle
The animation of the circle works fine in Firefox but fails to work smoothly in Chrome.
If I remove animation delay and duration from span element, like here, the circle is animated like it should.
What I'm doing wrong?
HTML:
<div class="box">
<div class="circle first">
<span>Lorem Ipsum</span>
</div>
</div>
CSS:
.circle {
position: absolute;
top: 50px;
left: 150px;
display: block;
border-radius: 50%;
-webkit-transition: box-shadow .25s;
transition: box-shadow .25s;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
// animation
-webkit-clip-path: circle(0 at 50% 50%);
clip-path: circle(0 at 50% 50%);
-webkit-animation-name: scale-up;
animation-name: scale-up;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-transition-timing-function: cubic-bezier(0, 0, .2, 1);
transition-timing-function: cubic-bezier(0, 0, .2, 1);
-webkit-animation-duration: 1s;
animation-duration: 1s;
background-color: #323232;
}
.circle span {
position: absolute;
top: 20px;
right: 50%;
display: block;
background-color: green;
padding: .4em .6em .3em;
webkit-transform: translateX(100%);
transform: translateX(100%);
-webkit-animation-name: slide-left;
animation-name: slide-left;
-webkit-animation-duration: 1.5s;
animation-duration: 1.5s;
-webkit-animation-delay: 1.5s;
animation-delay: 1.5s;
}
.first {
width: 17em;
height: 17em;
-webkit-animation-delay: .5s;
animation-delay: .5s;
box-shadow: 0 0 0 1.6em rgba(32, 32, 32, .1);
}
// Scale up
#-webkit-keyframes scale-up {
0% {
-webkit-clip-path: circle(0 at 50% 50%);
clip-path: circle(0 at 50% 50%);
}
99% {
-webkit-clip-path: circle(60% at 50% 50%);
clip-path: circle(60% at 50% 50%);
}
100% {
-webkit-clip-path: none;
clip-path: none;
}
}
#keyframes scale-up {
0% {
-webkit-clip-path: circle(0 at 50% 50%);
clip-path: circle(0 at 50% 50%);
}
99% {
-webkit-clip-path: circle(60% at 50% 50%);
clip-path: circle(60% at 50% 50%);
}
100% {
-webkit-clip-path: none;
clip-path: none;
}
}
#-webkit-keyframes slide-left {
0% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
100% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#keyframes slide-left {
0% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
100% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
Hope I can help you with this solution: Actually, clip-path animation fails because of span that deforms the circle shape. A solution may be to extract span from its parent (circle) and move it directly into .box container. So, span become sibling of circle. Now, the circle clip-path recovered its regular shape. Then, by defining style to .box element, we also define a new container for the span that is able move following previous locations. here is the code: https://jsfiddle.net/nesquimo/jn3dnuhm/13/
.box{
position: relative;
top: 50px;
left: 150px;
width: 17em;
height: 17em;
}
.circle {
position: absolute;
display: block;
border-radius: 50%;
-webkit-transition: box-shadow .25s;
transition: box-shadow .25s;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
// animation
-webkit-clip-path: circle(0 at 50% 50%);
clip-path: circle(0 at 50% 50%);
-webkit-animation-name: scale-up;
animation-name: scale-up;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-transition-timing-function: cubic-bezier(0, 0, .2, 1);
transition-timing-function: cubic-bezier(0, 0, .2, 1);
-webkit-animation-duration: 1s;
animation-duration: 1s;
background-color: #323232;
}
.circle__band {
position: absolute;
top: 20px;
right: 50%;
opacity: 0;
display: block;
background-color: green;
padding: .4em .6em .3em;
transform: translate3D(100%, 0, 0);
animation-name: slide-left;
animation-fill-mode: forwards;
animation-duration: 1s;
animation-delay: 1.5s;
}
.first {
width: 17em;
height: 17em;
-webkit-animation-delay: .5s;
animation-delay: .5s;
box-shadow: 0 0 0 1.6em rgba(32, 32, 32, .1);
}
// Scale up
#-webkit-keyframes scale-up {
0% {
-webkit-clip-path: circle(0 at 50% 50%);
clip-path: circle(0 at 50% 50%);
}
99% {
-webkit-clip-path: circle(60% at 50% 50%);
clip-path: circle(60% at 50% 50%);
}
100% {
-webkit-clip-path: none;
clip-path: none;
}
}
#keyframes scale-up {
0% {
-webkit-clip-path: circle(0 at 50% 50%);
clip-path: circle(0 at 50% 50%);
}
99% {
-webkit-clip-path: circle(60% at 50% 50%);
clip-path: circle(60% at 50% 50%);
}
100% {
-webkit-clip-path: none;
clip-path: none;
}
}
// Slide left
#-webkit-keyframes slide-left {
0% {
opacity: 1;
transform: translate3D(100%,0,0);
}
100% {
opacity: 1;
transform: translate3D(0,0,0);
}
}
#keyframes slide-left {
0% {
opacity: 1;
transform: translate3D(100%,0,0);
}
100% {
opacity: 1;
transform: translate3D(0,0,0);
}
}
<div class="box">
<div class="circle first">
</div>
<span class="circle__band">Lorem Ipsum</span>
</div>

Delay animation, make it go the other direction after Xs

I'm getting more into animation property and keyframes. Got this loader thing I'm working on. I'm having a hard time getting to go from right to left with animation-delay and multiple animations approach.
This one dot is supposed to go from left > right, right > left.
Stop there for until the other dots pass back the other direction and start again, stop there until the other dots pass back....
My approach is:
Full solution at jsfiddle
body {
background-color: #111111;
}
[data-am-animation] {
box-sizing: border-box;
background-color: white;
flex-direction: row;
margin: 30px;
position: relative;
height: 180px;
width: 120px;
}
[data-am-animation] .dot {
background-color: deepskyblue;
position: absolute;
height: 30px;
width: 30px;
border-radius: 50%;
}
[data-am-animation] .dot.down {
left: 30px;
animation-name: load-down;
animation-duration: 5s;
animation-timing-function: linear;
animation-direction: alternate;
animation-iteration-count: infinite;
}
[data-am-animation] .dot.up {
left: 60px;
animation-name: load-up;
animation-duration: 5s;
animation-timing-function: linear;
animation-direction: alternate;
animation-iteration-count: infinite;
}
[data-am-animation] .dot.through {
left: 0;
top: 50%;
margin-top: -15px;
/*animation-name: load-through;
animation-duration: ($animation-speed / 2.6);
animation-timing-function: linear;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-delay: ($animation-speed / 1.3);*/
animation: load-through-right 1.66667s linear infinite 3.125s, load-through-left 1.66667s linear infinite 3.125s;
}
/* keyframes start */
#keyframes load-down {
0% {
transform: translate(0, 0);
background-color: deepskyblue;
}
100% {
transform: translate(0, 150px);
background-color: deeppink;
}
}
#keyframes load-up {
0% {
transform: translate(0, 150px);
background-color: deeppink;
}
100% {
transform: translate(0, 0);
background-color: deepskyblue;
}
}
#keyframes load-through-right {
0% {
transform: translate(0, 0);
background-color: deepskyblue;
}
100% {
transform: translate(90px, 0);
background-color: deeppink;
}
}
#keyframes load-through-left {
0% {
transform: translate(90px, 0);
background-color: deeppink;
}
100% {
transform: translate(0, 0);
background-color: deepskyblue;
}
}
/* keyframes end */
<div data-am-animation>
<div class="dot through"></div>
<div class="dot down"></div>
<div class="dot up"></div>
</div>
any suggestions for math improvements, I'm all for it.
EDIT
Final result
Here is an approach with single animation. Let me know if it's a direction for you or may I didn't understand your wish.
body {
background-color: #111111;
}
[data-am-animation] {
box-sizing: border-box;
background-color: white;
flex-direction: row;
margin: 30px;
position: relative;
height: 180px;
width: 120px;
}
[data-am-animation] .dot {
background-color: deepskyblue;
position: absolute;
height: 30px;
width: 30px;
border-radius: 50%;
}
[data-am-animation] .dot.down {
left: 30px;
animation-name: load-down;
animation-duration: 5s;
animation-timing-function: linear;
animation-direction: alternate;
animation-iteration-count: infinite;
}
[data-am-animation] .dot.up {
left: 60px;
animation-name: load-up;
animation-duration: 5s;
animation-timing-function: linear;
animation-direction: alternate;
animation-iteration-count: infinite;
}
[data-am-animation] .dot.through {
left: 0;
top: 50%;
margin-top: -15px;
/*animation-name: load-through;
animation-duration: ($animation-speed / 2.6);
animation-timing-function: linear;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-delay: ($animation-speed / 1.3);*/
animation: load-through-right 5s linear infinite;
}
/* keyframes start */
#keyframes load-down {
0% {
transform: translate(0, 0);
background-color: deepskyblue;
}
100% {
transform: translate(0, 150px);
background-color: deeppink;
}
}
#keyframes load-up {
0% {
transform: translate(0, 150px);
background-color: deeppink;
}
100% {
transform: translate(0, 0);
background-color: deepskyblue;
}
}
#keyframes load-through-right {
0%, 20% {
transform: translate(0, 0);
background-color: deepskyblue;
}
50%, 70% {
transform: translate(90px, 0);
background-color: deeppink;
}
}
#keyframes load-through-left {
0% {
transform: translate(90px, 0);
background-color: deeppink;
}
100% {
transform: translate(0, 0);
background-color: deepskyblue;
}
}
/* keyframes end */
<div data-am-animation>
<div class="dot through"></div>
<div class="dot down"></div>
<div class="dot up"></div>
</div>

CSS loading animation not running

Sorry for the vague title, but essentially I copied some code from CodePen where it works flawlessly, but I can't get the exact same code to work in my project, or a jsFiddle I created.
Here's the relevant HTML:
<div class="loader loader--flipDelay loader--3d">
<span class="loader-item">1</span>
...
</div>
And the CSS for webkit browsers:
.loader-item {
display: inline-block;
width: 50px;
height: 50px;
margin-left: 2px;
background-color: rgba(61, 92, 126, 0.7);
color: rgba(61, 92, 126, 0.7);
-webkit-animation-duration: 2000ms;
-webkit-animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
-webkit-animation-iteration-count: infinite;
}
.loader--flipDelay .loader-item {
-webkit-animation-name: flipDelay;
}
#keyframes flipDelay {
0% {
transform: rotateX(0deg);
transform-origin: 0 0 0;
opacity: 1;
}
30% {
transform: rotateX(90deg);
transform-origin: 0 0 0;
opacity: 0;
}
40% {
transform-origin: 0 0 0;
}
60% {
transform: rotateX(90deg);
opacity: 0;
transform-origin: 0 100% 0;
}
90% {
transform: rotateX(0deg);
opacity: 1;
transform-origin: 0 100% 0;
}
}
Here's the CodePen which looks great.
I attempted to copy all the code into my project, and the elements are there, but absolutely nothing happens to them.
Here's a jsFiddle which shows the code not running. Please note that this code is only prefixed to work in Chrome and other webkit browsers.
My first thought was that it was a prefixing problem, but after removing all the warnings, still nothing happens to those loader-items.
Your code is missing -webkit- prefixes for #keyframes.
I've added vendor prefix for the rest of the browsers as well.
Fiddle
body {
font-family: 'PT Sans', sans-serif;
text-align: center;
background-color: #000;
padding-top: 40px;
}
h1,
h2 {
background-color: rgba(200, 200, 200, 0.2);
padding: 20px;
text-transform: uppercase;
color: #fff;
}
h1 {
font-size: 24px;
margin-bottom: 40px;
}
h1 a {
display: block;
margin-top: 10px;
text-transform: none;
color: #aaa;
font-size: 16px;
text-decoration: none;
}
h2 {
font-size: 16px;
margin-bottom: 15%;
}
.loader {
display: block;
overflow: hidden;
margin-bottom: 15%;
font-size: 0;
}
.loader--3d {
transform-style: preserve-3d;
-webkit-perspective: 800px;
perspective: 800px;
}
.loader--slideBoth {
overflow: visible;
}
.loader-item {
display: inline-block;
width: 50px;
height: 50px;
margin-left: 2px;
background-color: rgba(61, 92, 126, 0.7);
color: rgba(61, 92, 126, 0.7);
-webkit-animation-duration: 2000ms;
-webkit-animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
-webkit-animation-iteration-count: infinite;
animation-duration: 2000ms;
animation-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
animation-iteration-count: infinite;
}
.loader-item:nth-child(1) {
-webkit-animation-delay: 100ms;
animation-delay: 100ms;
}
.loader-item:nth-child(2) {
-webkit-animation-delay: 200ms;
animation-delay: 200ms;
}
.loader-item:nth-child(3) {
-webkit-animation-delay: 300ms;
animation-delay: 300ms;
}
.loader-item:nth-child(4) {
-webkit-animation-delay: 400ms;
animation-delay: 400ms;
}
.loader-item:nth-child(5) {
-webkit-animation-delay: 500ms;
animation-delay: 500ms;
}
.loader-item:nth-child(6) {
-webkit-animation-delay: 600ms;
animation-delay: 600ms;
}
.loader--slowFlip .loader-item {
-webkit-animation-name: slowFlip;
animation-name: slowFlip;
}
.loader--flipHoz .loader-item {
-webkit-animation-name: flipHoz;
animation-name: flipHoz;
}
.loader--fade .loader-item {
-webkit-animation-name: fade;
-webkit-animation-duration: 1000ms;
animation-duration: 1000ms;
animation-name: fade;
}
.loader--slowFlip .loader-item:nth-child(1),
.loader--flipHoz .loader-item:nth-child(1) {
-webkit-animation-delay: 150ms;
animation-delay: 150ms;
}
.loader--slowFlip .loader-item:nth-child(2),
.loader--flipHoz .loader-item:nth-child(2) {
-webkit-animation-delay: 300ms;
animation-delay: 300ms;
}
.loader--slowFlip .loader-item:nth-child(3),
.loader--flipHoz .loader-item:nth-child(3) {
-webkit-animation-delay: 450ms;
animation-delay: 450ms;
}
.loader--slowFlip .loader-item:nth-child(4),
.loader--flipHoz .loader-item:nth-child(4) {
-webkit-animation-delay: 600ms;
animation-delay: 600ms;
}
.loader--slowFlip .loader-item:nth-child(5),
.loader--flipHoz .loader-item:nth-child(5) {
-webkit-animation-delay: 750ms;
animation-delay: 750ms;
}
.loader--slowFlip .loader-item:nth-child(6),
.loader--flipHoz .loader-item:nth-child(6) {
-webkit-animation-delay: 900ms;
animation-delay: 900ms;
}
.loader--flipDelay .loader-item {
-webkit-animation-name: flipDelay;
animation-name: flipDelay;
}
.loader--flipDelayDown .loader-item {
-webkit-animation-name: flipDelay;
-webkit-animation-direction: reverse;
animation-name: flipDelay;
animation-direction: reverse;
}
.loader--slideDown .loader-item,
.loader--slideUp .loader-item {
-webkit-animation-name: slideDown;
-webkit-animation-duration: 800ms;
-webkit-animation-timing-function: linear;
animation-name: slideDown;
animation-duration: 800ms;
animation-timing-function: linear;
}
.loader--slideDown .loader-item {
transform-origin: top left;
}
.loader--slideUp .loader-item {
transform-origin: bottom left;
}
.loader--slideBoth .loader-item {
-webkit-animation-name: slideBoth;
-webkit-animation-duration: 1000ms;
transform-origin: bottom left;
-webkit-animation-timing-function: linear;
animation-name: slideBoth;
animation-duration: 1000ms;
animation-timing-function: linear;
}
/**********************************/
/* KEYFRAME ANIMATION DEFINITIONS */
/**********************************/
#-webkit-keyframes slowFlip {
0% {
transform: rotateX(0deg);
}
40% {
transform: rotateX(180deg);
}
100% {
transform: rotateX(180deg);
}
}
#-webkit-keyframes flipHoz {
0% {
transform: rotateY(0deg);
}
40% {
transform: rotateY(180deg);
}
100% {
transform: rotateY(180deg);
}
}
#-webkit-keyframes fade {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#-webkit-keyframes flipDelay {
0% {
transform: rotateX(0deg);
transform-origin: 0 0 0;
opacity: 1;
}
30% {
transform: rotateX(90deg);
transform-origin: 0 0 0;
opacity: 0;
}
40% {
transform-origin: 0 0 0;
}
60% {
transform: rotateX(90deg);
opacity: 0;
transform-origin: 0 100% 0;
}
90% {
transform: rotateX(0deg);
opacity: 1;
transform-origin: 0 100% 0;
}
}
#-webkit-keyframes slideDown {
0% {
transform: rotateX(0deg);
}
50% {
transform: rotateX(90deg);
}
}
#-webkit-keyframes slideBoth {
0% {
transform: rotateX(0deg);
}
100% {
transform: rotateX(360deg);
}
}
#keyframes slowFlip {
0% {
transform: rotateX(0deg);
}
40% {
transform: rotateX(180deg);
}
100% {
transform: rotateX(180deg);
}
}
#keyframes flipHoz {
0% {
transform: rotateY(0deg);
}
40% {
transform: rotateY(180deg);
}
100% {
transform: rotateY(180deg);
}
}
#keyframes fade {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes flipDelay {
0% {
transform: rotateX(0deg);
transform-origin: 0 0 0;
opacity: 1;
}
30% {
transform: rotateX(90deg);
transform-origin: 0 0 0;
opacity: 0;
}
40% {
transform-origin: 0 0 0;
}
60% {
transform: rotateX(90deg);
opacity: 0;
transform-origin: 0 100% 0;
}
90% {
transform: rotateX(0deg);
opacity: 1;
transform-origin: 0 100% 0;
}
}
#keyframes slideDown {
0% {
transform: rotateX(0deg);
}
50% {
transform: rotateX(90deg);
}
}
#keyframes slideBoth {
0% {
transform: rotateX(0deg);
}
100% {
transform: rotateX(360deg);
}
}
<h1>A collection of loaders using CSS 2D and 3D transforms created by #AshNolan_</h1>
<h2>Flip Delay Up</h2>
<div class="loader loader--flipDelay loader--3d"> <span class="loader-item">1</span>
<span class="loader-item">2</span>
<span class="loader-item">3</span>
<span class="loader-item">4</span>
<span class="loader-item">5</span>
<span class="loader-item">6</span>
</div>
That's not CSS. That's Sass, a language that compiles to CSS; while it doesn't add new styling capabilities (that's the browser's job), it does have a lot of language features that let you write simpler, cleaner, and less repetitive stylesheets. No browser can use Sass out of the gate; it has to be compiled to CSS first.
True as that is, I missed the point of the question. See the answer(s) above.

Resources