I want to have my font awesome icon "ring" each 1 seconds, by ring I mean having a css animation which makes the phone look like if it where ringing (maybe a brief rotation with transform origin center?), I'm a noob with css animations:
<div style="width:50px; height:50px; border-radius:50%; display:flex; align-items:center; justify-content:center; background-color:white;"><i class="LAYOUTnav7_links_button_icon fa fa-phone fs_bigger main"></i></div>
Any help?
You can use animation and keyframes to do this, here is an example:
.phone {
display:block;
width: 60px;
height: 60px;
font-size: 40px;
margin:50px auto 0;
color: #9e9e9e;
animation: ring 4s .7s ease-in-out infinite;
transform-origin: 50% 4px;
}
#keyframes ring {
0% { transform: rotate(0); }
5% { transform: rotate(30deg); }
10% { transform: rotate(-28deg); }
15% { transform: rotate(34deg); }
20% { transform: rotate(-32deg); }
25% { transform: rotate(30deg); }
30% { transform: rotate(-28deg); }
35% { transform: rotate(26deg); }
40% { transform: rotate(-24deg); }
45% { transform: rotate(22deg); }
50% { transform: rotate(-20deg); }
55% { transform: rotate(18deg); }
60% { transform: rotate(-16deg); }
65% { transform: rotate(14deg); }
70% { transform: rotate(-12deg); }
75% { transform: rotate(10deg); }
80% { transform: rotate(-8deg); }
85% { transform: rotate(6deg); }
90% { transform: rotate(-4deg); }
95% { transform: rotate(2deg); }
100% { transform: rotate(-1deg); }
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<div>
<span class="phone fa fa-phone"></span>
</div>
Related
.anim-cat-2 img {
animation: animcats 10s infinite;
}
#keyframes animcats {
0% {
transform: translate(100px, 100px)rotate(-15deg);
}
10% {
transform: translate(150px, -100px) rotate(15deg);
}
20% {
transform: rotate(-15deg) translate(200px, 100px);
}
30% {
transform: rotate(15deg)translate(250px, -100px);
}
40% {
transform: rotate(-15deg)translate(300px, 100px);
}
50% {
transform: rotate(15deg)translate(350px, -100px);
}
60% {
transform: rotate(-15deg)translate(400px, 100px);
}
70% {
transform: rotate(15deg)translate(450px, -100px);
}
80% {
transform: rotate(-15deg)translate(500px, 100px);
}
90% {
transform: rotate(15deg)translate(550px, -100px);
}
100% {
transform: rotate(-15deg)translate(600 px, 100px);
}
}
<div class="anim-cat-2">
<img src="https://66.media.tumblr.com/95927edf9e85ece73dac69ade623432c/tumblr_otrmgaTiin1vxe4v6o1_400.png" style="height: 130px;width: 180px;margin-top: 20px;">
</div>
i cant make it go smoothly forward in right tilt, its suppossed to make the right angle and move up and down moving forward. i already tried to change the degree, x n y axis but it still didnt work,please help me
Run code snippet.
Although it makes the right angle, move up and down, it did'nt meets the expectation at the end of the animation.
.anim-cat-2 img {
animation: animcats 8s infinite;
}
#keyframes animcats {
0% {
transform: rotate(0deg) translate(0px,0px);
}
8% {
transform: rotate(9deg);
}
10% {
transform: translate(100px,150px);
}
20% {
transform:rotate(-9deg) translate(100px,150px);
}
30% {
transform: translate(200px,0px);
}
40% {
transform: rotate(9deg) translate(200px,0px);
}
50% {
transform: translate(300px,150px);
}
60% {
transform: rotate(-9deg) translate(300px,150px);
}
70% {
transform: translate(400px,0px);
}
80% {
transform: rotate(9deg) translate(400px,0px);
}
90% {
transform: translate(500px,150px);
}
100% {
transform: rotate(-9deg) translate(500px,150px);
}
}
<div class="anim-cat-2">
<img src="https://66.media.tumblr.com/95927edf9e85ece73dac69ade623432c/tumblr_otrmgaTiin1vxe4v6o1_400.png" style="height: 130px;width: 180px;margin-top: 20px;">
</div>
I have two images moving around a DOM element. But their rotation is wrong and the movement is not smooth.
My fiddle
#mainPage {
width: 400px;
height: 165px;
margin: 10% auto;
}
#mainPage>p {
text-align: center;
}
.bicycle {
width: 48px;
height: 30px;
background: red;
}
#bicycleOriginal {
animation: moveBicycleOriginal 20s infinite;
}
#bicycleFlipped {
animation: moveBicycleFlipped 20s infinite;
}
#mainTxt {
letter-spacing: 7px;
font-size: 30px;
margin-bottom: 30px;
}
#keyframes moveBicycleOriginal {
from {
transform: translate(0, 0);
}
1% {
transform: translate(0, 0) rotate(0deg);
}
25% {
transform: translate(350px, 0);
}
26% {
transform: translate(350px, 0) rotate(90deg);
}
50% {
transform: translate(350px, 150px);
}
51% {
transform: translate(350px, 150px) rotate(180deg);
}
75% {
transform: translate(0, 150px);
}
76% {
transform: translate(0, 150px) rotate(270deg);
}
to {
transform: translate(0, 0);
}
}
#keyframes moveBicycleFlipped {
from {
transform: translate(350px, 0);
}
1% {
transform: translate(350px, 0) rotate(0deg);
}
25% {
transform: translate(0, 0);
}
26% {
transform: translate(0, 0) rotate(90deg);
}
50% {
transform: translate(0, -150px);
}
51% {
transform: translate(0, -150px) rotate(180deg);
}
75% {
transform: translate(350px, -150px);
}
76% {
transform: translate(350px, -150px) rotate(270deg);
}
to {
transform: translate(350px, 0);
}
}
<div id="mainPage">
<div class="bicycle" id="bicycleOriginal"></div>
<p class="txt" id="mainTxt">DRAHTESEL</p>
<div class="bicycle" id="bicycleFlipped"></div>
</div>
So what I want is something like this
After passing the first keyframe the boxes get into a wrong rotation. Also they don't move smoothly, the get faster in the middle and slower when reaching the end.
Could someone help me with the keyframes?
You need to always keep the rotate defined within the transform because each transform will override the previous one and removing the rotation means rotate(0).
And to make the animation more accurate, the last state should be similar to the first state to avoid the jump when restarting the animation. So you should go to 360deg of rotation which is equivalent to 0deg. (like you did with the translation where you come back to the initial value).
Then you may adjust the animation-timing-function to control the animation progress if needed.
#mainPage {
width: 400px;
height: 165px;
margin: 10% auto;
}
#mainPage>p {
text-align: center;
}
.bicycle {
width: 48px;
height: 30px;
background: red;
}
#bicycleOriginal {
animation: moveBicycleOriginal 20s infinite;
}
#bicycleFlipped {
animation: moveBicycleFlipped 20s infinite;
}
#mainTxt {
letter-spacing: 7px;
font-size: 30px;
margin-bottom: 30px;
}
#keyframes moveBicycleOriginal {
from {
transform: translate(0, 0) rotate(0deg);
}
25% {
transform: translate(350px, 0) rotate(0deg);
}
26% {
transform: translate(350px, 0) rotate(90deg);
}
50% {
transform: translate(350px, 150px) rotate(90deg);
}
51% {
transform: translate(350px, 150px) rotate(180deg);
}
75% {
transform: translate(0, 150px) rotate(180deg);
}
76% {
transform: translate(0, 150px) rotate(270deg);
}
98% {
transform: translate(0, 0) rotate(270deg);
}
to {
transform: translate(0, 0) rotate(360deg);
}
}
#keyframes moveBicycleFlipped {
from {
transform: translate(350px, 0) rotate(0deg);
}
25% {
transform: translate(0, 0) rotate(0deg);
}
26% {
transform: translate(0, 0) rotate(90deg);
}
50% {
transform: translate(0, -150px) rotate(90deg);
}
51% {
transform: translate(0, -150px) rotate(180deg);
}
75% {
transform: translate(350px, -150px) rotate(180deg);
}
76% {
transform: translate(350px, -150px) rotate(270deg);
}
97% {
transform: translate(350px, 0) rotate(270deg);
}
to {
transform: translate(350px, 0) rotate(360deg);
}
}
<div id="mainPage">
<div class="bicycle" id="bicycleOriginal"></div>
<p class="txt" id="mainTxt">DRAHTESEL</p>
<div class="bicycle" id="bicycleFlipped"></div>
</div>
The speed slowing/speeding is because of the animationTiming (default ease), that should be 'linear'.
The reason the animation is incorrect, it because you unset the rotation. This might come unexpected, you control transformation with css transform. You also control rotation with transform.
#example{
transform: rotate(10deg)
}
#example.changed{
transform: translateX(100px);
}
In this snippet, when you add the class changed you redefine transform, telling it to forget rotate and set translateX. In this example, to keep them both:
#example.changed{
transform: rotate(10deg) translateX(100px);
}
I have taken the answer from Temani Afif, and changed it a little bit.
I set an aditional transform, applied after the rotation. This makes the turn be smooth in the sense that the object rotates following a path and not in the same place
I have set the timing to linear, as suggested by Martijn
I have simplified it to use a single keyframes rule, setting a delay on the flipped div.
And made longer the time slice for the long sides and shoprter the other, so that the perceived speed is more constant
The result:
#mainPage {
width: 400px;
height: 165px;
margin: 10% auto;
}
#mainPage>p {
text-align: center;
}
.bicycle {
width: 48px;
height: 30px;
background: red;
}
#bicycleOriginal {
animation: moveBicycleOriginal 20s infinite linear;
}
#bicycleFlipped {
position: relative;
top: -120px;
animation: moveBicycleOriginal 20s -10s infinite linear;
}
#mainTxt {
letter-spacing: 7px;
font-size: 30px;
margin-bottom: 30px;
}
#keyframes moveBicycleOriginal {
from {
transform: translate(0, 0) rotate(0deg) translate(0, -50px);
}
26% {
transform: translate(350px, 0) rotate(0deg) translate(0, -50px);
}
30% {
transform: translate(350px, 0) rotate(90deg) translate(0, -50px);
}
46% {
transform: translate(350px, 150px) rotate(90deg) translate(0, -50px);
}
50% {
transform: translate(350px, 150px) rotate(180deg) translate(0, -50px);
}
76% {
transform: translate(0, 150px) rotate(180deg) translate(0, -50px);
}
80% {
transform: translate(0, 150px) rotate(270deg) translate(0, -50px);
}
96% {
transform: translate(0, 0) rotate(270deg) translate(0, -50px);
}
to {
transform: translate(0, 0) rotate(360deg) translate(0, -50px);
}
}
<div id="mainPage">
<div class="bicycle" id="bicycleOriginal"></div>
<p class="txt" id="mainTxt">DRAHTESEL</p>
<div class="bicycle" id="bicycleFlipped"></div>
</div>
I have a set of absolute divs having background images which contains animation.
when i apply scale property to the divs it messes up my z-index totally
here is the link to the fiddle https://jsfiddle.net/kq2soozp/3/ (Uncomment transform:scale() line)
The HTML Code
<div class='me'>
<div class="torso">
<div class="left leg">
<div class="left thigh">
<div class="left shin">
<div class="left foot">
<div class="left toes"></div>
</div>
</div>
</div>
</div>
<div class="right leg">
<div class="right thigh">
<div class="right shin">
<div class="right foot">
<div class="right toes"></div>
</div>
</div>
</div>
</div>
<div class="left arm">
<div class="left bicep">
<div class="left forearm">
<div class="kite"></div>
</div>
</div>
</div>
<div class="right arm">
<div class="right bicep">
<div class="right forearm"></div>
</div>
</div>
</div>
</div>
The CSS
.me,.me div{
background-repeat: no-repeat;
position: absolute;
-webkit-animation-duration: 2000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
//-webkit-transform: scale(0.9);
}
.me{
top: 80px;
left: 350px;
-webkit-animation-name: me;
}
.torso{
height: 274px;
width: 86px;
background-image: url("https://s9.postimg.org/41xfy5cin/torso.png");
}
.arm{
left: 12px;
-webkit-transform-origin: 20px 10px;
}
.kite{
width: 395px;
height: 424px;
top: -115px;
left: 0px;
background-image: url("https://s3.postimg.org/ix240ioab/kite.png");
-webkit-transform: rotate(45deg) scale(0.6);
}
.right.bicep{
width: 51px;
height: 124px;
background-image: url("https://s3.postimg.org/mlrszzyb7/right-bicep.png");
}
.left.bicep{
width: 52px;
: 126px;
background-image: url("https://s3.postimg.org/jb3g048dv/left-bicep.png");
}
.left.forearm{
width: 37px;
height: 124px;
background-image: url("https://s3.postimg.org/7ahzze0z7/left-forearm.png");
-webkit-transform: rotate(-45deg);
}
.right.forearm{
width: 36px;
height: 121px;
background-image: url("https://s3.postimg.org/q6noj82ur/right-forearm.png");
-webkit-animation-name: right-forearm;
}
.left.thigh{
width: 69px;
height: 144px;
background-image: url("https://s3.postimg.org/577krq16b/left-thigh.png");
}
.right.thigh{
width: 69px;
height: 144px;
background-image: url("https://s3.postimg.org/72ud2vq0j/right-thigh.png");
}
.shin{
width: 53px;
height: 173px;
background-image: url("https://s3.postimg.org/3xecqews3/shin.png");
}
.foot{
width: 67px;
height: 34px;
background-image: url("https://s3.postimg.org/l0cj86o37/foot.png");
}
.toes{
width: 28px;
height: 25px;
background-image: url("https://s3.postimg.org/vm0zxxjsj/toes.png");
}
.right.arm{
top: 93px;
-webkit-animation-name: right-bicep;
}
.left.arm{
top: 87px;
-webkit-transform: rotate(-26deg);
}
.forearm{
top: 108px;
left: 14px;
-webkit-transform-origin: 3px 7px;
}
.leg{
left: 6px;
-webkit-transform-origin: 30px 20px;
-webkit-animation-name: thigh;
}
.right.leg{
top: 235px;
-webkit-animation-name: right-thigh;
}
.left.leg{
top:225px;
-webkit-animation-name: left-thigh;
}
.shin{
top: 115px;
-webkit-transform-origin: 30px 25px;
}
.right.shin {
-webkit-animation-name: right-shin;
}
.left.shin {
-webkit-animation-name: left-shin;
}
.foot{
top: 155px;
left: 2px;
-webkit-transform-origin: 0 50%;
}
.right.foot {
-webkit-animation-name: right-foot;
}
.left.foot {
-webkit-animation-name: left-foot;
}
.toes{
top: 9px;
left: 66px;
-webkit-transform-origin: 0% 100%;
}
.right.toes {
-webkit-animation-name: right-toes;
}
.left.toes {
-webkit-animation-name: left-toes;
}
div.right.arm { z-index: 1; }
div.left.arm { z-index: -3; }
div.arm > div.bicep > div.forearm { z-index: -1; }
div.right.leg { z-index: -1; }
div.left.leg { z-index: -2; }
div.leg > div.thigh > div.shin { z-index: -1; }
#-webkit-keyframes me {
0% { -webkit-transform: rotate(5deg) translate( 10px, 0px); }
25% { -webkit-transform: rotate(5deg) translate(-5px, -14px); }
50% { -webkit-transform: rotate(5deg) translate( 10px, 0px); }
75% { -webkit-transform: rotate(5deg) translate(-5px, -14px); }
100% { -webkit-transform: rotate(5deg) translate( 10px, 0px); }
}
#-webkit-keyframes right-bicep {
0% { -webkit-transform: rotate(26deg); }
50% { -webkit-transform: rotate(-20deg); }
100% { -webkit-transform: rotate(26deg); }
}
/*#-webkit-keyframes left-bicep {
0% { -webkit-transform: rotate(-20deg); }
50% { -webkit-transform: rotate(26deg); }
100% { -webkit-transform: rotate(-20deg); }
}*/
#-webkit-keyframes right-forearm {
0% { -webkit-transform: rotate(-10deg); }
50% { -webkit-transform: rotate(-65deg); }
100% { -webkit-transform: rotate(-10deg); }
}
/*#-webkit-keyframes left-forearm {
0% { -webkit-transform: rotate(-45deg); }
50% { -webkit-transform: rotate(-10deg); }
100% { -webkit-transform: rotate(-45deg); }
}*/
#-webkit-keyframes right-thigh {
0% { -webkit-transform: rotate(-45deg); }
50% { -webkit-transform: rotate(10deg); }
100% { -webkit-transform: rotate(-45deg); }
}
#-webkit-keyframes left-thigh {
0% { -webkit-transform: rotate(10deg); }
50% { -webkit-transform: rotate(-45deg); }
100% { -webkit-transform: rotate(10deg); }
}
#-webkit-keyframes right-shin {
0% { -webkit-transform: rotate(30deg); }
25% { -webkit-transform: rotate(20deg); }
50% { -webkit-transform: rotate(20deg); }
75% { -webkit-transform: rotate(85deg); }
100% { -webkit-transform: rotate(30deg); }
}
#-webkit-keyframes left-shin {
0% { -webkit-transform: rotate(20deg); }
25% { -webkit-transform: rotate(85deg); }
50% { -webkit-transform: rotate(30deg); }
75% { -webkit-transform: rotate(20deg); }
100% { -webkit-transform: rotate(20deg); }
}
#-webkit-keyframes right-foot {
0% { -webkit-transform: rotate(-5deg); }
25% { -webkit-transform: rotate(-7deg); }
50% { -webkit-transform: rotate(-16deg); }
75% { -webkit-transform: rotate(-10deg); }
100% { -webkit-transform: rotate(-5deg); }
}
#-webkit-keyframes left-foot {
0% { -webkit-transform: rotate(-16deg); }
25% { -webkit-transform: rotate(-10deg); }
50% { -webkit-transform: rotate(-5deg); }
75% { -webkit-transform: rotate(-7deg); }
100% { -webkit-transform: rotate(-16deg); }
}
#-webkit-keyframes right-toes {
0% { -webkit-transform: rotate(0deg); }
25% { -webkit-transform: rotate(-10deg); }
50% { -webkit-transform: rotate(-10deg); }
75% { -webkit-transform: rotate(-25deg); }
100% { -webkit-transform: rotate(0deg); }
}
#-webkit-keyframes left-toes {
0% { -webkit-transform: rotate(-10deg); }
25% { -webkit-transform: rotate(-25deg); }
50% { -webkit-transform: rotate(0deg); }
75% { -webkit-transform: rotate(-10deg); }
100% { -webkit-transform: rotate(-10deg); }
}
Please help me solve this issue. I looked into the other post about this problem but I am not able to correct it.
Thank you
You can read this one
z-index is canceled by setting transform(rotate)
basically, transforming an element using 'transform' which gives the element its own stacking context that is different than other element which is not transformed. What you can do is make all element to transform, for example:
<div class="a"><img src="..."></div>
<div class="b"><img src="..."></div>
you want div 'a' to scale(0.9) and be on top of 'b'. you can make the div 'b' to transform to translate(0,0) or scale(0) which won't make any different. Or you can just transform the content inside of it (for my example it's an image element) instead of the div that wrapping it. then just apply the z-index to div.
Since the transform property resets the stacking order of the elements, what i did is a wrapper div to the class "me" and apply transform scale property to the wrapper to reduce the size
.wrapper{
-webkit-transform: scale(0.4);
}
here is the link to the working fiddle https://jsfiddle.net/kq2soozp/5/
It's not the z-index that is getting messed up, it's the relative size of the inner divs in relation to the main .me div. You resize .me to 90% of its original size, and then resize all the divs inside as well, so they end up at 81% of their original sizes.
Solution: apply the scale only to the .me and not to the divs in it.
.wrapper {
position: relative;
}
.me,
.me div {
background-repeat: no-repeat;
position: absolute;
animation-duration: 2000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.me {
top: 80px;
left: 350px;
transform: scale(0.9); /* moved here */
}
.torso {
height: 274px;
width: 86px;
background-image: url("https://s9.postimg.org/41xfy5cin/torso.png");
}
.arm {
left: 12px;
transform-origin: 20px 10px;
}
.kite {
width: 395px;
height: 424px;
top: -115px;
left: 0px;
background-image: url("https://s3.postimg.org/ix240ioab/kite.png");
transform: rotate(45deg) scale(0.6);
}
.right.bicep {
width: 51px;
height: 124px;
background-image: url("https://s3.postimg.org/mlrszzyb7/right-bicep.png");
}
.left.bicep {
width: 52px;
height: 126px;
background-image: url("https://s3.postimg.org/jb3g048dv/left-bicep.png");
}
.left.forearm {
width: 37px;
height: 124px;
background-image: url("https://s3.postimg.org/7ahzze0z7/left-forearm.png");
transform: rotate(-45deg);
}
.right.forearm {
width: 36px;
height: 121px;
background-image: url("https://s3.postimg.org/q6noj82ur/right-forearm.png");
animation-name: right-forearm;
}
.left.thigh {
width: 69px;
height: 144px;
background-image: url("https://s3.postimg.org/577krq16b/left-thigh.png");
}
.right.thigh {
width: 69px;
height: 144px;
background-image: url("https://s3.postimg.org/72ud2vq0j/right-thigh.png");
}
.shin {
width: 53px;
height: 173px;
background-image: url("https://s3.postimg.org/3xecqews3/shin.png");
}
.foot {
width: 67px;
height: 34px;
background-image: url("https://s3.postimg.org/l0cj86o37/foot.png");
}
.toes {
width: 28px;
height: 25px;
background-image: url("https://s3.postimg.org/vm0zxxjsj/toes.png");
}
.right.arm {
top: 93px;
animation-name: right-bicep;
}
.left.arm {
top: 87px;
transform: rotate(-26deg);
}
.forearm {
top: 108px;
left: 14px;
transform-origin: 3px 7px;
}
.leg {
left: 6px;
transform-origin: 30px 20px;
animation-name: thigh;
}
.right.leg {
top: 235px;
animation-name: right-thigh;
}
.left.leg {
top: 225px;
animation-name: left-thigh;
}
.shin {
top: 115px;
transform-origin: 30px 25px;
}
.right.shin {
animation-name: right-shin;
}
.left.shin {
animation-name: left-shin;
}
.foot {
top: 155px;
left: 2px;
transform-origin: 0 50%;
}
.right.foot {
animation-name: right-foot;
}
.left.foot {
animation-name: left-foot;
}
.toes {
top: 9px;
left: 66px;
transform-origin: 0% 100%;
}
.right.toes {
animation-name: right-toes;
}
.left.toes {
animation-name: left-toes;
}
div.right.arm {
z-index: 1;
}
div.left.arm {
z-index: -3;
}
div.arm>div.bicep>div.forearm {
z-index: -1;
}
div.right.leg {
z-index: -1;
}
div.left.leg {
z-index: -2;
}
div.leg>div.thigh>div.shin {
z-index: -1;
}
#keyframes me {
0% {
transform: rotate(5deg) translate( 5px, 0px);
}
25% {
transform: rotate(5deg) translate(-5px, -14px);
}
50% {
transform: rotate(5deg) translate( 5px, 0px);
}
75% {
transform: rotate(5deg) translate(-5px, -14px);
}
100% {
transform: rotate(5deg) translate( 5px, 0px);
}
}
#keyframes right-bicep {
0% {
transform: rotate(26deg);
}
50% {
transform: rotate(-20deg);
}
100% {
transform: rotate(26deg);
}
}
/*#keyframes left-bicep {
0% { transform: rotate(-20deg); }
50% { transform: rotate(26deg); }
100% { transform: rotate(-20deg); }
}*/
#keyframes right-forearm {
0% {
transform: rotate(-10deg);
}
50% {
transform: rotate(-65deg);
}
100% {
transform: rotate(-10deg);
}
}
/*#keyframes left-forearm {
0% { transform: rotate(-45deg); }
50% { transform: rotate(-10deg); }
100% { transform: rotate(-45deg); }
}*/
#keyframes right-thigh {
0% {
transform: rotate(-45deg);
}
50% {
transform: rotate(10deg);
}
100% {
transform: rotate(-45deg);
}
}
#keyframes left-thigh {
0% {
transform: rotate(10deg);
}
50% {
transform: rotate(-45deg);
}
100% {
transform: rotate(10deg);
}
}
#keyframes right-shin {
0% {
transform: rotate(30deg);
}
25% {
transform: rotate(20deg);
}
50% {
transform: rotate(20deg);
}
75% {
transform: rotate(85deg);
}
100% {
transform: rotate(30deg);
}
}
#keyframes left-shin {
0% {
transform: rotate(20deg);
}
25% {
transform: rotate(85deg);
}
50% {
transform: rotate(30deg);
}
75% {
transform: rotate(20deg);
}
100% {
transform: rotate(20deg);
}
}
#keyframes right-foot {
0% {
transform: rotate(-5deg);
}
25% {
transform: rotate(-7deg);
}
50% {
transform: rotate(-16deg);
}
75% {
transform: rotate(-10deg);
}
100% {
transform: rotate(-5deg);
}
}
#keyframes left-foot {
0% {
transform: rotate(-16deg);
}
25% {
transform: rotate(-10deg);
}
50% {
transform: rotate(-5deg);
}
75% {
transform: rotate(-7deg);
}
100% {
transform: rotate(-16deg);
}
}
#keyframes right-toes {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(-10deg);
}
50% {
transform: rotate(-10deg);
}
75% {
transform: rotate(-25deg);
}
100% {
transform: rotate(0deg);
}
}
#keyframes left-toes {
0% {
transform: rotate(-10deg);
}
25% {
transform: rotate(-25deg);
}
50% {
transform: rotate(0deg);
}
75% {
transform: rotate(-10deg);
}
100% {
transform: rotate(-10deg);
}
}
<div class="wrapper">
<div class='me'>
<div class="torso">
<div class="left leg">
<div class="left thigh">
<div class="left shin">
<div class="left foot">
<div class="left toes"></div>
</div>
</div>
</div>
</div>
<div class="right leg">
<div class="right thigh">
<div class="right shin">
<div class="right foot">
<div class="right toes"></div>
</div>
</div>
</div>
</div>
<div class="left arm">
<div class="left bicep">
<div class="left forearm">
<div class="kite"></div>
</div>
</div>
</div>
<div class="right arm">
<div class="right bicep">
<div class="right forearm"></div>
</div>
</div>
</div>
</div>
</div>
By the way, some remarks:
// for a comment is an error in CSS. Don't do this. It happens to have no effect in your fiddle, but just look at this fiddle where it goes wrong.
You don't need the vendor prefixes during testing. Remove them and the code works in all browsers. If you want to be backwards compatible with older ones, fine, you can add in the prefixed properties (above the unprefixed ones), but do that after you're done twiddling with them.
I'm trying to create a folding effect in a hexagon composed of triangles. So far I've only managed to make the triangles translate instead of folding over. I want to make
this http://jsfiddle.net/zn6jbhr6/
Relevant SCSS
#mixin hexTranslateKeyFrames($name, $degree) {
#keyframes #{$name} {
#content;
}
}
$hex-degree: 0deg;
#for $idx from 1 through 6 {
$hex-degree: $hex-degree + 60;
#include hexTranslateKeyFrames(hexTranslate#{$idx}, $hex-degree) {
0% { transform: rotateZ(0deg) rotate($hex-degree); }
54.55%, 100% { transform: rotateZ(360deg) rotate($hex-degree); }
}
}
$order2: (0s, 0.2s, 0.4s, 0.6s, 0.8s, 1s);
.folding-hex {
#include hexagon();
#for $i from 1 through 6 {
.triangle:nth-child(#{$i}) {
animation: hexTranslate#{$i} 2.2s infinite #{nth($order2, $i)} linear;
}
}
}
more like this http://jsfiddle.net/wvm15yL4/
Relevant CSS
.sk-folding-cube .sk-cube {
float: left;
width: 50%;
height: 50%;
position: relative;
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
}
.sk-folding-cube .sk-cube:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #333;
-webkit-animation: sk-foldCubeAngle 2.4s infinite linear both;
animation: sk-foldCubeAngle 2.4s infinite linear both;
-webkit-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
.sk-folding-cube .sk-cube2 {
-webkit-transform: scale(1.1) rotateZ(90deg);
transform: scale(1.1) rotateZ(90deg);
}
.sk-folding-cube .sk-cube3 {
-webkit-transform: scale(1.1) rotateZ(180deg);
transform: scale(1.1) rotateZ(180deg);
}
.sk-folding-cube .sk-cube4 {
-webkit-transform: scale(1.1) rotateZ(270deg);
transform: scale(1.1) rotateZ(270deg);
}
.sk-folding-cube .sk-cube2:before {
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.sk-folding-cube .sk-cube3:before {
-webkit-animation-delay: 0.6s;
animation-delay: 0.6s;
}
.sk-folding-cube .sk-cube4:before {
-webkit-animation-delay: 0.9s;
animation-delay: 0.9s;
}
#-webkit-keyframes sk-foldCubeAngle {
0%, 10% {
-webkit-transform: perspective(140px) rotateX(-180deg);
transform: perspective(140px) rotateX(-180deg);
opacity: 0;
} 25%, 75% {
-webkit-transform: perspective(140px) rotateX(0deg);
transform: perspective(140px) rotateX(0deg);
opacity: 1;
} 90%, 100% {
-webkit-transform: perspective(140px) rotateY(180deg);
transform: perspective(140px) rotateY(180deg);
opacity: 0;
}
}
#keyframes sk-foldCubeAngle {
0%, 10% {
-webkit-transform: perspective(140px) rotateX(-180deg);
transform: perspective(140px) rotateX(-180deg);
opacity: 0;
} 25%, 75% {
-webkit-transform: perspective(140px) rotateX(0deg);
transform: perspective(140px) rotateX(0deg);
opacity: 1;
} 90%, 100% {
-webkit-transform: perspective(140px) rotateY(180deg);
transform: perspective(140px) rotateY(180deg);
opacity: 0;
}
}
You need to create an animation that rotates in 3D.
Since it is a little hard, I have done it only once, and reused it for the other elements setting an intermediate element in the DOM that does the rotation in the plane
The first 2 parameters in the rotate3D are sin(60deg) and cos(60deg), to make the rotation axis be at 60 deg
#keyframes flip {
0% { transform: rotate3d( 0.5, 0.866, 0, 90deg);
opacity: 0;}
0.1% { transform: rotate3d( 0.5, 0.866, 0, 90deg);
opacity: 1;}
14% { transform: rotate3d( 0.5, 0.866, 0, 0deg); }
50% { transform: rotate3d(-0.5, 0.866, 0, 0deg); }
63.99% { transform: rotate3d(-0.5, 0.866, 0, -90deg);
opacity: 1;}
64%, 100% { transform: rotate3d(-0.5, 0.866, 0, -90deg);
opacity: 0}
}
.folding-hex {
height: 69.28px;
width: 80px;
position: relative;
margin: 0 auto;
transform-origin: 0 0;
transform: translateX(40px) rotate(30deg); }
.rotator {
transform-origin: 20px 37.64px;
}
.rotator:nth-child(1) {
transform: rotate(0deg);
}
.rotator:nth-child(2) {
transform: rotate(60deg);
}
.rotator:nth-child(3) {
transform: rotate(120deg);
}
.rotator:nth-child(4) {
transform: rotate(180deg);
}
.rotator:nth-child(5) {
transform: rotate(240deg);
}
.rotator:nth-child(6) {
transform: rotate(300deg);
}
.triangle {
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 34.64px 20px 0;
transform-origin: 20px 37.64px;
border-color: #E50C4E transparent;
animation: flip 3s linear infinite;
}
.rotator:nth-child(2) .triangle {
border-color: #b5093d transparent;
animation-delay: -2.5s;
}
.rotator:nth-child(3) .triangle {
border-color: #b5093d transparent;
animation-delay: -2.0s;
}
.rotator:nth-child(4) .triangle {
animation-delay: -1.5s;
}
.rotator:nth-child(5) .triangle {
border-color: #f8799f transparent;
animation-delay: -1.0s;
}
.rotator:nth-child(6) .triangle {
border-color: #f8799f transparent;
animation-delay: -0.5s;
}
<div class="folding-hex">
<div class="rotator">
<div class="triangle"></div>
</div>
<div class="rotator">
<div class="triangle"></div>
</div>
<div class="rotator">
<div class="triangle"></div>
</div>
<div class="rotator">
<div class="triangle"></div>
</div>
<div class="rotator">
<div class="triangle"></div>
</div>
<div class="rotator">
<div class="triangle"></div>
</div>
</div>
I am trying to create a CSS3 only animation that makes a span (one letter) look like it swings back and forth and then falls off the screen while turning. Here is my CSS:
#-webkit-keyframes swing {
10% { -webkit-transform: rotate(15deg); }
15% { -webkit-transform: rotate(-10deg); }
20% { -webkit-transform: rotate(5deg); }
25% { -webkit-transform: rotate(-5deg); }
30% { -webkit-transform: rotate(2deg); }
35% { -webkit-transform: rotate(-1deg); }
40% { -webkit-transform: rotate(0deg); }
75% { -webkit-transform: rotate(15deg); -webkit-transform: translate(0, 1500px); }
100% { -webkit-transform: rotate(15deg); -webkit-transform:translate(0, 1500px); }
}
#keyframes swing {
10% { transform: rotate(15deg); }
15% { transform: rotate(-10deg); }
20% { transform: rotate(5deg); }
25% { transform: rotate(-5deg); }
30% { transform: rotate(2deg); }
35% { transform: rotate(-1deg); }
40% { transform: rotate(0deg); }
75% { transform: rotate(15deg); -webkit-transform: translate(0, 1500px); }
100% { transform: rotate(15deg); -webkit-transform: translate(0, 1500px); }
}
.animateone {
display: inline-block;
-webkit-animation-name: swing;
animation-name: swing;
-webkit-transform-origin: top center;
transform-origin: top center;
-webkit-animation-duration: 3s;
animation-duration: 3s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
And here is the result: Result
Why isn't the 'A' rotating as it falls?
You should write your transforms into a single statement:
#keyframes swing {
75% { transform: rotate(700deg) translate(0, 1500px); }
100% { transform: rotate(700deg) translate(0, 1500px); }
}
UPDATED
If you want rotate when falling, you should use two animations separately:
#keyframes translate {
10% { transform: translate(0, 0); }
15% { transform: translate(0, 0); }
20% { transform: translate(0, 0); }
25% { transform: translate(0, 0); }
30% { transform: translate(0, 0); }
35% { transform: translate(0, 0); }
40% { transform: translate(0, 0); }
75% { transform: translate(0, 1500px); }
100% { transform: translate(0, 1500px); }
}
#keyframes rotate {
10% { transform: rotate(15deg); }
15% { transform: rotate(-10deg); }
20% { transform: rotate(5deg); }
25% { transform: rotate(-5deg); }
30% { transform: rotate(2deg); }
35% { transform: rotate(-1deg); }
40% { transform: rotate(0deg); }
75% { transform: rotate(700deg); }
100% { transform: rotate(700deg); }
}
.rotate {
display: inline-block;
animation-name: rotate;
transform-origin: top center;
animation-duration: 5s;
animation-fill-mode: both;
}
.translate {
display: inline-block;
animation-name: translate;
transform-origin: top center;
animation-duration: 5s;
animation-fill-mode: both;
}
<header>
<h1>W.I.P.<?h1>
<h2>
A Text
<span class="translate">
<span class="rotate">A</span>
</span>
dventure
</h2>
</header>
In first place, you can only set a transform property at a time. If you want to combine 2, set them in a comma separate list. (ROX was right about this).
In the second place, order of the transforms is important. If you want the span to move while rotating, the order must be the one that you see in the snippet.
I have also changed the transform origin, to make it visually more smooth, and changed the animation to linear for the same reason. Nut of course you can adjust it as you want
#-webkit-keyframes swing {
10% { transform: translate(0, 0px) rotate(15deg); transform-origin: top center;}
15% { transform: translate(0, 0px) rotate(-10deg); }
20% { transform: translate(0, 0px) rotate(5deg); }
25% { transform: translate(0, 0px) rotate(-5deg); }
30% { transform: translate(0, 0px) rotate(2deg); }
35% { transform: translate(0, 0px) rotate(-1deg); }
40% { transform: translate(0, 0px) rotate(0deg); transform-origin: top center;}
40% { transform: translate(0, 0px) rotate(0deg); transform-origin: center center;}
75% { transform: translate(0, 150px) rotate(375deg); }
100% { transform: translate(0, 150px) rotate(375deg); transform-origin: top center;}
}
#keyframes swing {
10% { transform: translate(0, 0px) rotate(15deg); transform-origin: top center;}
15% { transform: translate(0, 0px) rotate(-10deg); }
20% { transform: translate(0, 0px) rotate(5deg); }
25% { transform: translate(0, 0px) rotate(-5deg); }
30% { transform: translate(0, 0px) rotate(2deg); }
35% { transform: translate(0, 0px) rotate(-1deg); }
40% { transform: translate(0, 0px) rotate(0deg); transform-origin: top center;}
40% { transform: translate(0, 0px) rotate(0deg); transform-origin: center center;}
75% { transform: translate(0, 150px) rotate(375deg); }
100% { transform: translate(0, 150px) rotate(375deg); transform-origin: top center;}
}
.animateone {
display: inline-block;
-webkit-animation: swing 3s infinite linear;
animation: swing 3s infinite linear;
transform-origin: top center;
}
<span class="animateone">A</a>