Pure CSS rotate animation broken while in infinite loop - html

It's been a while since I asked a question here. So excuse me if I do anything wrong.
I have an issue with CSS animation. I would like my animation to keep repeating it self but without loosing the initial effects. However it seems like there is a bug either in my code or in CSS animation behavior.
After it completes first 2 rotate animations (spin, spinback) defined. The loop begins but the new animation is not as same as before.
My goal is to create rotate animation on 6 boxes in order, one at a time. When all boxes turned, they should start turning back to original state again in order, one by one.
Code:
/* -------------------------------------------------------- */
#loader {
width: 240px;
height: 100px;
}
.inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 2s;
transform-style: preserve-3d;
background-color: transparent;
}
.front,
.back {
position: absolute;
width: 80px;
height: 50px;
backface-visibility: hidden;
}
/* -------------------------------------------------------- */
#loader1 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader1 .inner {
animation: spin 10s ease 0s infinite, spinback 10s ease 10s infinite;
-webkit-animation: spin 10s ease 0s infinite, spinback 10s ease 10s infinite;
}
#loader1 .front {
background-color: #db9834;
}
#loader1 .back {
background-color: #3498db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader2 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader2 .inner {
animation: spin 10s ease 1s infinite, spinback 10s ease 11s infinite;
-webkit-animation: spin 10s ease 1s infinite, spinback 10s ease 11s infinite;
}
#loader2 .front {
background-color: #db8834;
}
#loader2 .back {
background-color: #3488db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader3 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader3 .inner {
animation: spin 10s ease 2s infinite, spinback 10s ease 12s infinite;
-webkit-animation: spin 10s ease 2s infinite, spinback 10s ease 12s infinite;
}
#loader3 .front {
background-color: #db7834;
}
#loader3 .back {
background-color: #3478db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader4 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader4 .inner {
animation: spin 10s ease 3s infinite, spinback 10s ease 13s infinite;
-webkit-animation: spin 10s ease 3s infinite, spinback 10s ease 13s infinite;
}
#loader4 .front {
background-color: #db6834;
}
#loader4 .back {
background-color: #3468db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader5 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader5 .inner {
animation: spin 10s ease 4s infinite, spinback 10s ease 14s infinite;
-webkit-animation: spin 10s ease 4s infinite, spinback 10s ease 14s infinite;
}
#loader5 .front {
background-color: #db5834;
}
#loader5 .back {
background-color: #3458db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader6 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader6 .inner {
animation: spin 10s ease 5s infinite, spinback 10s ease 15s infinite;
-webkit-animation: spin 10s ease 5s infinite, spinback 10s ease 15s infinite;
}
#loader6 .front {
background-color: #db4834;
}
#loader6 .back {
background-color: #3448db;
transform: rotateY(180deg);
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotateY(0deg);
}
16% {
-webkit-transform: rotateY(180deg);
}
100% {
-webkit-transform: rotateY(180deg);
}
}
#keyframes spin {
0% {
-webkit-transform: rotateY(0deg);
}
16% {
-webkit-transform: rotateY(180deg);
}
100% {
-webkit-transform: rotateY(180deg);
}
}
#-webkit-keyframes spinback {
0% {
-webkit-transform: rotateY(180deg);
}
16% {
-webkit-transform: rotateY(0deg);
}
100% {
-webkit-transform: rotateY(0deg);
}
}
#keyframes spinback {
0% {
-webkit-transform: rotateY(180deg);
}
16% {
-webkit-transform: rotateY(0deg);
}
100% {
-webkit-transform: rotateY(0deg);
}
}
<div id="loader">
<div id="loader1">
<div class="inner">
<div class="front">
</div>
<div class="back"> </div>
</div>
</div>
<div id="loader2">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader3">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader4">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader5">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader6">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
</div>
Just to make it more understandable I am trying to apply css flipcard method:
https://www.w3schools.com/howto/howto_css_flip_card.asp
On divs in order to create a look like something is loading...
The animation only gives timing to trigger keyframes in right timing then in key frames I am rotating divs and putting a wait time until oter divs finishes their rotation. So formula is 6 box in 10sec which is gonna be somewhere between (0% to 100%) so (100 / 6 = 16,6) which I take the animation as should end at 16% of the animation time.

First I would simplify your code and use less HTML/CSS. Then I would consider only one animation where I will have both states.
The animation will be: the first flip then we keep the first color then the second filp then we keep the second color. It's divided into 12 time slots (1 + 5 + 1 + 5) (1+5 = 6 which is the number of the divs)
If the duration is S then the delay should be multiple of one slot S/12. Notice that I have used the perspective within the transform to avoid an extra element:
#loader {
width: 240px;
height: 100px;
display: flex;
flex-wrap: wrap;
}
#loader>div {
width: calc(100%/3);
position: relative;
transform-style: preserve-3d;
animation: spin 6s linear var(--delay, 0s) infinite;
}
#loader>div:before,
#loader>div:after {
content: "";
position: absolute;
top:0;
left:0;
width: 100%;
height: 100%;
backface-visibility: hidden;
background-color: var(--front, #db9834);
}
#loader>div:after {
background-color: var(--back, #3498db);
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader>div:nth-child(2) {
--front: #db8834;
--back: #3488db;
--delay: 0.5s;
}
#loader>div:nth-child(3) {
--front: #db7834;
--back: #3478db;
--delay: 1s;
}
#loader>div:nth-child(4) {
--front: #db6834;
--back: #3468db;
--delay: 1.5s;
}
#loader>div:nth-child(5) {
--front: #db5834;
--back: #3458db;
--delay: 2s;
}
#loader>div:nth-child(6) {
--front: #db4834;
--back: #3448db;
--delay: 2.5s;
}
#keyframes spin {
0% {
transform:perspective(500px) rotateY(0deg);
}
8.33%,
50%{
transform:perspective(500px) rotateY(180deg);
}
58.33% {
transform:perspective(500px) rotateY(0deg);
}
}
<div id="loader">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
Related questions for more details about the difference between perspective and perspective()
CSS 3d transform doesn't work if perspective is set in the end of property
perspective and translateZ moves diagonally
We can simplify more if we change the div coloration while rotating instead of having two elements. The change should be made at half the slot where we do the flip (first and sixth) without any transition to create the illusion:
#loader {
width: 240px;
height: 100px;
display: flex;
flex-wrap: wrap;
}
#loader>div {
width: calc(100%/3);
animation:
spin 6s linear var(--delay, 0s) infinite,
colors 6s linear var(--delay, 0s) infinite;
background-color: var(--front, #db9834);
}
/* -------------------------------------------------------- */
#loader>div:nth-child(2) {
--front: #db8834;
--back: #3488db;
--delay: 0.5s;
}
#loader>div:nth-child(3) {
--front: #db7834;
--back: #3478db;
--delay: 1s;
}
#loader>div:nth-child(4) {
--front: #db6834;
--back: #3468db;
--delay: 1.5s;
}
#loader>div:nth-child(5) {
--front: #db5834;
--back: #3458db;
--delay: 2s;
}
#loader>div:nth-child(6) {
--front: #db4834;
--back: #3448db;
--delay: 2.5s;
}
#keyframes spin {
0% {
transform:perspective(500px) rotateY(0deg);
}
8.33%,
50%{
transform:perspective(500px) rotateY(180deg);
}
58.33% {
transform:perspective(500px) rotateY(0deg);
}
}
#keyframes colors {
0%,4.15% {
background-color: var(--front, #db9834);
}
4.16% {
background-color: var(--back, #3498db);
}
54.15% {
background-color: var(--back, #3498db);
}
54.16% {
background-color: var(--front, #db9834);
}
}
<div id="loader">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
Another simplification can be done using filter considering the fact that you want to have the same shades of colors:
#loader {
width: 240px;
height: 100px;
display: flex;
flex-wrap: wrap;
}
#loader>div {
width: calc(100%/3);
animation:
spin 6s linear var(--delay, 0s) infinite,
colors 6s linear var(--delay, 0s) infinite;
background:
linear-gradient(#db9834 50%, #3498db 0);
background-size: 100% 200%;
}
/* -------------------------------------------------------- */
#loader>div:nth-child(2) {
filter: brightness(0.9);
--delay: 0.5s;
}
#loader>div:nth-child(3) {
filter: brightness(0.8);
--delay: 1s;
}
#loader>div:nth-child(4) {
filter: brightness(0.7);
--delay: 1.5s;
}
#loader>div:nth-child(5) {
filter: brightness(0.6);
--delay: 2s;
}
#loader>div:nth-child(6) {
filter: brightness(0.5);
--delay: 2.5s;
}
#keyframes spin {
0% {
transform:perspective(500px) rotateY(0deg);
}
8.33%,
50%{
transform:perspective(500px) rotateY(180deg);
}
58.33% {
transform:perspective(500px) rotateY(0deg);
}
}
#keyframes colors {
4.15% {
background-position: top;
}
4.16%,
54.15% {
background-position:bottom;
}
54.16% {
background-position: top;
}
}
<div id="loader">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
This result is not exactly the same as I used a random filter but you can easily try another kind of filtration to get the needed result.

A similar problem has already been described on SO: How to have the object not revert to its initial position after animation has run? The problem is that at the beginning of the animation, the object returns to its original state. But I solved the problem differently: I simply combined both animations into one, and now both reversals are described by one function. If you definitely need both animations, then redo it, as stated in the question I've given link to. Here is my code:
#loader {
width: 240px;
height: 100px;
}
.inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 2s;
transform-style: preserve-3d;
background-color: transparent;
}
.front,
.back {
position: absolute;
width: 80px;
height: 50px;
backface-visibility: hidden;
}
#loader1 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader1 .inner {
animation: spin 20s ease 0s infinite;
-webkit-animation: spin 20s ease 0s infinite;
}
#loader1 .front {
background-color: #db9834;
}
#loader1 .back {
background-color: #3498db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader2 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader2 .inner {
animation: spin 20s ease 1s infinite;
-webkit-animation: spin 20s ease 1s infinite;
}
#loader2 .front {
background-color: #db8834;
}
#loader2 .back {
background-color: #3488db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader3 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader3 .inner {
animation: spin 20s ease 2s infinite;
-webkit-animation: spin 20s ease 2s infinite;
}
#loader3 .front {
background-color: #db7834;
}
#loader3 .back {
background-color: #3478db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader4 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader4 .inner {
animation: spin 20s ease 3s infinite;
-webkit-animation: spin 20s ease 3s infinite;
}
#loader4 .front {
background-color: #db6834;
}
#loader4 .back {
background-color: #3468db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader5 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader5 .inner{
animation: spin 20s ease 4s infinite;
-webkit-animation: spin 20s ease 4s infinite;
}
#loader5 .front {
background-color: #db5834;
}
#loader5 .back {
background-color: #3458db;
transform: rotateY(180deg);
}
/* -------------------------------------------------------- */
#loader6 {
float: left;
width: 80px;
height: 50px;
perspective: 1000px;
background-color: transparent;
}
#loader6 .inner {
animation: spin 20s ease 5s infinite;
-webkit-animation: spin 20s ease 5s infinite;
}
#loader6 .front {
background-color: #db4834;
}
#loader6 .back {
background-color: #3448db;
transform: rotateY(180deg);
}
#-webkit-keyframes spin {
0% {
-webkit-transform: rotateY(0deg);
}
8% {
-webkit-transform: rotateY(180deg);
}
50% {
-webkit-transform: rotateY(180deg);
}
58% {
-webkit-transform: rotateY(0deg);
}
100% {
-webkit-transform: rotateY(0deg);
}
}
#keyframes spin {
0% {
-webkit-transform: rotateY(0deg);
}
8% {
-webkit-transform: rotateY(180deg);
}
50% {
-webkit-transform: rotateY(180deg);
}
58% {
-webkit-transform: rotateY(0deg);
}
100% {
-webkit-transform: rotateY(0deg);
}
}
<div id="loader">
<div id="loader1">
<div class="inner">
<div class="front">
</div>
<div class="back"> </div>
</div>
</div>
<div id="loader2">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader3">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader4">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader5">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
<div id="loader6">
<div class="inner">
<div class="front"> </div>
<div class="back"> </div>
</div>
</div>
</div>

Related

Spinner acting out

Any ideas of what is happening here? Why does the purple box position itself outside the spinner for a moment there?
This is my css and rotate animation:
.spinner {
display: flex;
align-items: center;
justify-content: center;
background-color: red;
}
.spinner-ball {
border: 2px solid blue;
border-bottom-color: transparent;
border-radius: 100%;
height: 26px;
width: 26px;
background: transparent !important;
display: inline-block;
animation-fill-mode: both;
-webkit-animation-fill-mode: both;
animation: rotate 1s linear infinite;
-webkit-animation: rotate 1s linear infinite;
}
#keyframes rotate {
from {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
}
to {
transform: rotate(360deg);
-webkit-transform: rotate(360deg);
}
}
<div class="spinner">
<div class="spinner-ball" />
</div>

webkit-animation and linking issue

Having problem with hyperlinking a menu item. The menu has webkit animation attached. Inspired from a codepen demo to create a orbiting menu. The orbiting circle menu works fine. Somehow the hyperlinks are not working. Would appreciate if i can pause the webkit animation on menu hover. Point me in the right direction.
Here is the [codepen demo link] (https://codepen.io/aroganz/pen/ZEELqKr)
<div class="outCircle">
<div class="rotate anim1">
<div class="counterrotate">
<div class="inner">Home
</div>
</div>
</div>
<div class="rotate anim2">
<div class="counterrotate">
<div class="inner">Our Team
</div>
</div>
</div>
<div class="rotate anim3">
<div class="counterrotate">
<div class="inner">Our Servicces
</div>
</div>
</div>
<div class="rotate anim4">
<div class="counterrotate">
<div class="inner">Contact
</div>
</div>
</div>
</div>
The CSS Part
.outCircle {
width: 300px;
height: 300px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 150px;
-webkit-border-radius: 150px;
border-radius: 150px;
}
.rotate {
width: 100%;
height: 100%;
position: absolute; /* add this */
}
.counterrotate {
width: 100px;
height: 100px;
}
.inner {
width: 100px;
height: 100px;
text-align: center;
vertical-align: middle;
background: red;
border-radius: 100px;
background-color: red;
display: table-cell;
}
.anim1 {
-webkit-animation: circle1 35s infinite linear;
}
.anim1 .counterrotate {
-webkit-animation: ccircle1 35s infinite linear;
}
.anim2 {
-webkit-animation: circle2 35s infinite linear;
}
.anim2 .counterrotate {
-webkit-animation: ccircle2 35s infinite linear;
}
.anim3 {
-webkit-animation: circle3 35s infinite linear;
}
.anim3 .counterrotate {
-webkit-animation: ccircle3 35s infinite linear;
}
.anim4{
-webkit-animation: circle4 35s infinite linear;
}
.anim4 .counterrotate {
-webkit-animation: ccircle4 35s infinite linear;
}
#-webkit-keyframes circle1 {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(360deg)
}
}
#-webkit-keyframes ccircle1 {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(-360deg)
}
}
#-webkit-keyframes circle2 {
from {
-webkit-transform: rotateZ(90deg)
}
to {
-webkit-transform: rotateZ(450deg)
}
}
#-webkit-keyframes ccircle2 {
from {
-webkit-transform: rotateZ(-90deg)
}
to {
-webkit-transform: rotateZ(-450deg)
}
}
#-webkit-keyframes circle3 {
from {
-webkit-transform: rotateZ(180deg)
}
to {
-webkit-transform: rotateZ(540deg)
}
}
#-webkit-keyframes ccircle3 {
from {
-webkit-transform: rotateZ(-180deg)
}
to {
-webkit-transform: rotateZ(-540deg)
}
}
#-webkit-keyframes circle4 {
from {
-webkit-transform: rotateZ(270deg)
}
to {
-webkit-transform: rotateZ(630deg)
}
}
#-webkit-keyframes ccircle4 {
from {
-webkit-transform: rotateZ(-270deg)
}
to {
-webkit-transform: rotateZ(-630deg)
}
}
Would appreciate if i can pause the webkit animation on menu hover.
Since there is lots of different animations on different elements involved here, the easiest way to do this would be something along the lines of
.outCircle:hover * {
animation-play-state: paused !important;
}
When the container element gets hovered, the animation play state for all children gets set to paused, !important added so that it overwrite any states that might be set differently elsewhere.
You can be a bit more specific with the selector though here, since there’s two classes of elements that are animated, so make that
.outCircle:hover .rotate, .outCircle:hover .counterrotate {
animation-play-state: paused !important;
}

Why does first slideshow image click skip transition and go straight to image?

In the slideshow shown below, there are two images available. Once clicking on a button for the second image after first opening my page, there is a sudden jump to that image with no 5 second transition as expected. Also when doing this, I notice that #slideshowimage-2 is shown in the url (doing this offline) after clicking the button for that image. Here's the code below:
CSS:
.slideshowcontainer {
width:800px;
height:400px;
margin-left:auto;
margin-right:auto;
margin-top:0px;
text-align:center;
overflow:hidden;
position:relative;
top:30px;
border-style:solid;
border-width:10px;
border-color:white;
border-radius:15px;
}
.imagecontainer {
width:1800px;
height:400px;
clear: both;
position:relative;
-webkit-transition:left 3s;
-moz-transition:left 3s;
-o-transition:left 3s;
-ms-transition:left 3s;
transition:left 3s;
animation:scroller 16s infinite;
}
#keyframes scroller {
0% {transform:translateX(0);}
31.25% {transform:translateX(0);}
50% {transform:translateX(-800px);}
81.25% {transform:translateX(-800px);}
100% {transform:translateX(0);}
}
.slideshowimage {
float:left;
margin:0px;
padding:0px;
position:relative;
}
#keyframes change {
0% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
animation: scroller 16s infinite;
}
}
#keyframes change2 {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
animation: scroller2 16s infinite;
}
}
#slideshowimage-1:target ~ .imagecontainer {
animation: none;
transform: translateX(0px);
animation: change 3s forwards;
}
#slideshowimage-2:target ~ .imagecontainer {
animation: none;
transform: translateX(-800px);
animation: change2 3s forwards;
}
.buttoncontainer {
position:relative;
top:-20px;
}
.button {
display:inline-block;
height:10px;
width:10px;
border-radius:10px;
background-color:darkgray;
-webkit-transition:background-color 0.25s;
-moz-transition:background-color 0.25s;
-o-transition:background-color 0.25s;
-ms-transition:background-color 0.25s;
transition:background-color 0.25s;
}
.button:hover {
background-color:gray;
}
HTML:
<div class="slideshowcontainer">
<span id="slideshowimage-1"></span>
<span id="slideshowimage-2"></span>
<span id="slideshowimage-3"></span>
<div class="imagecontainer">
<img src="WebServiceSlide.png" class="slideshowimage" style="width:800px;height:400px;">
<img src="es-flag.png" class="slideshowimage" style="width:800px;height:400px;">
</div>
<div class="buttoncontainer">
</div>
</div>
How could I make it so that the transition set upon clicking a button occurs on the first click? Many thanks in advance.
Reason:-
Because the left and translateX both are different. If you apply left:-800px when slide is at translateX(-800px) (2nd slide) then animation will continue at the 2nd part of slideshow. Thats why you are seeing a blank white space(when translateX(-800px) accors when it is already left:-800px).
Solution:-
You either have to use translateX or left. use the same in all the places
Part of code that solved the problem:-
#keyframes change {
0% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
animation: scroller 16s infinite;
}
}
#keyframes change2 {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
animation: scroller2 16s infinite;
}
}
#slideshowimage-1:target ~ .imagecontainer {
animation: none;
transform: translateX(0px);
animation: change 3s forwards;
}
#slideshowimage-2:target ~ .imagecontainer {
animation: none;
transform: translateX(-800px);
animation: change2 3s forwards;
}
Explanation:-
This code doesn't do translateX manually. Instead it uses animation to scoll single time by animation: change 3s forwards;
Drawback:-
Once we click on the slide selection button the animation stops. I have even tried it to solve by adding animation in the change keyframes animate end section. But unfortunately it didn't work. So I would suggest an alternate method to overcome the drawback as follows
To overcome the drawback I have added a play button which
will replay the slideshow animation which got paused by the slide
button. (Once we click on play button it takes a little time to slide
as we have given 16s in animation)
DEMO:-
.slideshowcontainer {
width: 800px;
height: 400px;
margin-left: auto;
margin-right: auto;
margin-top: 0px;
text-align: center;
overflow: hidden;
position: relative;
top: 30px;
border-style: solid;
border-width: 10px;
border-color: white;
border-radius: 15px;
}
.imagecontainer {
width: 1800px;
height: 400px;
clear: both;
position: relative;
-webkit-transition: all 3s;
-moz-transition: all 3s;
-o-transition: all 3s;
-ms-transition: all 3s;
transition: all 3s;
transform: translateX(0px);
animation: scroller 16s infinite;
}
#keyframes scroller {
0% {
transform: translateX(0);
}
31.25% {
transform: translateX(0);
}
50% {
transform: translateX(-800px);
}
81.25% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
}
}
#keyframes scroller2 {
0% {
transform: translateX(-800px);
}
31.25% {
transform: translateX(-800px);
}
50% {
transform: translateX(0);
}
81.25% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
}
}
#keyframes change {
0% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
animation: scroller 16s infinite;
}
}
#keyframes change2 {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
animation: scroller2 16s infinite;
}
}
.slideshowimage {
float: left;
margin: 0px;
padding: 0px;
position: relative;
}
#slideshowimage-1:target ~ .imagecontainer {
animation: none;
transform: translateX(0px);
animation: change 3s forwards;
}
#slideshowimage-2:target ~ .imagecontainer {
animation: none;
transform: translateX(-800px);
animation: change2 3s forwards;
}
#slideshowimage-3:target ~ .imagecontainer {
transform: translateX(0);
animation: scroller 16s infinite;
}
.buttoncontainer {
position: relative;
top: -20px;
}
.button {
display: inline-block;
height: 10px;
width: 10px;
border-radius: 10px;
background-color: darkgray;
-webkit-transition: background-color 0.25s;
-moz-transition: background-color 0.25s;
-o-transition: background-color 0.25s;
-ms-transition: background-color 0.25s;
transition: background-color 0.25s;
}
.button:hover {
background-color: gray;
}
.buttonplay:after {
height: 0;
width: 0;
top: 0;
margin-left: 10px;
position: absolute;
content: ' ';
border-left: solid 13px darkgray;
border-top: solid 8px transparent;
border-bottom: solid 8px transparent;
}
<div class="slideshowcontainer">
<span id="slideshowimage-1"></span>
<span id="slideshowimage-2"></span>
<span id="slideshowimage-3"></span>
<div class="imagecontainer">
<img src="https://placehold.it/800x400" class="slideshowimage" style="width:800px;height:400px;">
<img src="https://placehold.it/900x450" class="slideshowimage" style="width:800px;height:400px;">
</div>
<div class="buttoncontainer">
</div>
</div>

How to Flip the div in time intervals

Hi please look at this script and tell me how to flip A B and C divs in time intervals. I want A to flip first then it stops, B flips next and stops, and C next and Back to A, B and C again like in a loop and start it over again. Is this possible in CSS3 ? In this code all the divs flip on the same time.
/* ::: HOLDER, CARD, FACES */
.holder {
display: inline-block;
width: 64px;
height: 64px;
perspective: 700px;
}
.card, .front, .back{
position: absolute;
height: inherit;
width: inherit;
transition: all .7s;
transform-style: preserve-3d;
backface-visibility: hidden;
}
/* ::: FACES */
.front{background: tomato;}
.back{background: slategray;}
/* ::: SETUP FACES */
.flipH .back{transform: rotateY(-180deg);}
.flipV .back{transform: rotateX(180deg);}
/* ::: HOVER EFFECTS (Remove Automated for this to work) */
.flipH:hover .card{ transform: rotateY(180deg); }
.flipV:hover .card{ transform: rotateX(-180deg); }
/* ::: AUTOMATED EFFECTS */
.flipH .card{
animation: flipH 2s 0s infinite alternate ease-in-out;
-webkit-animation: flipH 2s 0s infinite alternate ease-in-out;
}
.flipV .card{
animation: flipV 2s 0s infinite alternate ease-in-out;
-webkit-animation: flipV 2s 0s infinite alternate ease-in-out;
}
#keyframes flipH {
0% { transform: rotateY(0deg); }
100% { transform: rotateY(-180deg); }
}
#-webkit-keyframes flipH {
0% { transform: rotateY(0deg); }
100% { transform: rotateY(-180deg); }
}
#keyframes flipV {
0% { transform: rotateX(0deg); }
100% { transform: rotateX(-180deg); }
}
#-webkit-keyframes flipV {
0% { transform: rotateX(0deg); }
100% { transform: rotateX(-180deg); }
}
<div class="holder flipH">
<div class="card">
<div class="front">A</div>
<div class="back">A</div>
</div>
</div>
<div class="holder flipV">
<div class="card">
<div class="front">B</div>
<div class="back">B</div>
</div>
</div>
<div class="holder flipH">
<div class="card">
<div class="front">C</div>
<div class="back">C</div>
</div>
</div>
As Maddy says, animation delay is the trick
/* ::: HOLDER, CARD, FACES */
.holder {
display: inline-block;
width: 64px;
height: 64px;
perspective: 700px;
}
.card, .front, .back{
position: absolute;
height: inherit;
width: inherit;
transition: all .7s;
transform-style: preserve-3d;
backface-visibility: hidden;
}
/* ::: FACES */
.front{background: tomato;}
.back{background: slategray;}
/* ::: SETUP FACES */
.flipH .back{transform: rotateY(-180deg);}
.flipV .back{transform: rotateX(180deg);}
/* ::: HOVER EFFECTS (Remove Automated for this to work) */
.flipH:hover .card{ transform: rotateY(180deg); }
.flipV:hover .card{ transform: rotateX(-180deg); }
/* ::: AUTOMATED EFFECTS */
.flipH .card{
animation: flipH 3s 0s infinite alternate ease-in-out;
-webkit-animation: flipH 3s 0s infinite alternate ease-in-out;
}
.flipV .card{
animation: flipV 3s 1s infinite alternate ease-in-out;
-webkit-animation: flipV 3s 1s infinite alternate ease-in-out;
}
.flipH:nth-child(3) .card {
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
#keyframes flipH {
0% { transform: rotateY(0deg); }
100% { transform: rotateY(-180deg); }
}
#-webkit-keyframes flipH {
0% { transform: rotateY(0deg); }
100% { transform: rotateY(-180deg); }
}
#keyframes flipV {
0% { transform: rotateX(0deg); }
100% { transform: rotateX(-180deg); }
}
#-webkit-keyframes flipV {
0% { transform: rotateX(0deg); }
100% { transform: rotateX(-180deg); }
}
<div class="holder flipH">
<div class="card">
<div class="front">A</div>
<div class="back">A</div>
</div>
</div>
<div class="holder flipV">
<div class="card">
<div class="front">B</div>
<div class="back">B</div>
</div>
</div>
<div class="holder flipH">
<div class="card">
<div class="front">C</div>
<div class="back">C</div>
</div>
</div>
There is in css3 2 type of tag animation-delay and animation-iteration-count, you need to google for that.
I think you want something like this-
.holder {
display: inline-block;
width: 64px;
height: 64px;
perspective: 700px;
}
.card, .front, .back{
position: absolute;
height: inherit;
width: inherit;
transition: all .7s;
transform-style: preserve-3d;
backface-visibility: hidden;
}
/* ::: FACES */
.front{background: tomato;}
.back{background: slategray;}
/* ::: SETUP FACES */
.flipH .back{transform: rotateY(-180deg);}
.flipV .back{transform: rotateX(180deg);}
/* ::: HOVER EFFECTS (Remove Automated for this to work) */
.flipH:hover .card{ transform: rotateY(180deg); }
.flipV:hover .card{ transform: rotateX(-180deg); }
/* ::: AUTOMATED EFFECTS */
.flipH .card{
animation: flipH 2s 0s 1 alternate ease-in-out;
-webkit-animation: flipH 2s 0s infinite alternate ease-in-out;
}
.flipV .card{
animation: flipV 2s 1s 1 alternate ease-in-out;
-webkit-animation: flipV 2s 0s infinite alternate ease-in-out;
}
.flipH.flipH2 .card{
animation: flipH 2s 2s 1 alternate ease-in-out;
-webkit-animation: flipH 2s 0s infinite alternate ease-in-out;
}
#keyframes flipH {
0% { transform: rotateY(0deg); }
100% { transform: rotateY(-180deg); }
}
#-webkit-keyframes flipH {
0% { transform: rotateY(0deg); }
100% { transform: rotateY(-180deg); }
}
#keyframes flipV {
0% { transform: rotateX(0deg); }
100% { transform: rotateX(-180deg); }
}
#-webkit-keyframes flipV {
0% { transform: rotateX(0deg); }
100% { transform: rotateX(-180deg); }
}
<div class="holder flipH">
<div class="card">
<div class="front">A</div>
<div class="back">A</div>
</div>
</div>
<div class="holder flipV">
<div class="card">
<div class="front">B</div>
<div class="back">B</div>
</div>
</div>
<div class="holder flipH flipH2">
<div class="card">
<div class="front">C</div>
<div class="back">C</div>
</div>
</div>
I hope it will helps you.

CSS vehicle animation

I'm trying to animate a tractor moving across the screen. I've got it working perfectly on my screen, however I want it to work across different platforms (only included -webkit-). When I re-size, the tractor is fluid, but the wheels aren't. How can I make them adjust together?
<body>
<div class="container">
<div class="tractor">
<img src="img/tractor-700px.png" alt="tractor">
</div>
<div class="wheels">
<div class="b_wheel">
<img src="img/b_wheel.png">
</div>
<div class="f_wheel">
<img src="img/f_wheel.png">
</div>
</div>
</div>
Here's my main CSS:
.tractor {
width: 380px;
position: absolute;
top: 40%;
left: -5%;
}
.tractor img {
width: 100%;
}
.tractor::after {
content: "";
display: block;
width: 120px;
height: 120px;
background: url('img/steam.png') no-repeat;
background-size: 120px;
position: absolute;
top: -37%;
left: 56%;
opacity: 0;
}
.f_wheel {;
width: 125px;
position: absolute;
top: 66.5%;
left: 13%;
}
.f_wheel img {
width: 100%;
}
.b_wheel {
width: 190px;
position: absolute;
top: 58.8%;
left: -7%;
}
.b_wheel img {
width: 100%;
}
And CSS for the animation:
.tractor {
-webkit-animation: tractor-bounce 3s ease-in-out infinite,
tractor-go 10s ease-in-out forwards;
}
.tractor::after {
-webkit-animation: steam 4s 2s infinite;
}
.f_wheel,
.b_wheel {
-webkit-animation: wheel-spin 10s ease-in-out forwards;
}
.f_wheel {
-webkit-animation: front-wheel-go 10s ease-in-out forwards,
wheel-spin 10s ease-in-out forwards;
}
.b_wheel {
-webkit-animation: back-wheel-go 10s ease-in-out forwards,
wheel-spin 10s ease-in-out forwards;
}
/* Keyframes - WebKit only
------------------------------------------ */
#-webkit-keyframes tractor-bounce {
50% { -webkit-transform: rotate(-5deg) translateY(-3px); }
}
#-webkit-keyframes tractor-go {
100% { left: 70%; }
}
#-webkit-keyframes steam {
40% { opacity: .8; }
60% { opacity: 1; }
100% { -webkit-transform: translate(-15%, -35%) rotateZ(20deg); }
}
#-webkit-keyframes wheel-spin {
0% { -webkit-transform: translateX(0px) rotate(50deg); }
100% { -webkit-transform: translateX(0px) rotate(480deg); }
}
#-webkit-keyframes front-wheel-go {
100% { left: 88%; }
}
#-webkit-keyframes back-wheel-go {
100% { left: 68.5%; }
}
JSFiddle to show it in action: http://jsfiddle.net/0j5L92vh/1/
[PS - This is my first post here so many thanks in advance! Let me know if I need to include anything else.]
I found a solution to your problem.
I utilized the .container div you have provided to keep everything positioned relative
to your tractor image. You can see the changes in the css code that made will make
it work in non webkit browsers. It will not work on versions of Internet Explorer before number 9.
The changes I have made are only to your css.
jsfiddle: http://jsfiddle.net/larryjoelane/h324j6u6/113/
css:
.container{
width: 380px;
position: relative;
/*bind the animation and set its properties*/
-webkit-animation: tractor 10s linear 0s; /* Chrome, Safari, Opera */
animation: tractor 10s linear 0s;
}
/*bind the wheel-spin animation*/
.f_wheel,
.b_wheel {
-webkit-animation: wheel-spin 10s ease-in-out forwards;
animation: wheel-spin 10s ease-in-out forwards;
}
/*bind the tractor bounce-animation*/
.tractor {
-webkit-animation: tractor-bounce 3s ease-in-out infinite,
tractor-go 10s ease-in-out forwards;
animation: tractor-bounce 3s ease-in-out infinite,
tractor-go 10s ease-in-out forwards;
}
.tractor img{
width:100%;
}
.b_wheel {
width: 190px;
position: relative;
top: -120px;
left: -7%;
}
.b_wheel img {
width: 100%;
}
.f_wheel{
width: 125px;
position:relative;
top: -258px;
left: 65%;
}
.f_wheel img {
width: 100%;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes tractor {
0% { left:0px; top:0px;}
25% {left:200px; top:0px;}
50% {left:400px; top:0px;}
75% {left:600px; top:0px;}
100% {left:800px; top:0px;}
}
/* Standard syntax */
#keyframes tractor {
0% { left:0px; top:0px;}
25% {left:200px; top:0px;}
50% {left:400px; top:0px;}
75% {left:600px; top:0px;}
100% {left:800px; top:0px;}
}
/*standard browser animation*/
#keyframes wheel-spin{
0% { transform: translateX(0px) rotate(50deg); }
100% { transform: translateX(0px) rotate(480deg); }
}
/*webkit browser animation*/
#-webkit-keyframes wheel-spin{
0% { -webkit-transform: translateX(0px) rotate(50deg); }
100% { -webkit-transform: translateX(0px) rotate(480deg); }
}
/*webkit tractor-bounce animation*/
#-webkit-keyframes tractor-bounce {
50% { -webkit-transform: rotate(-5deg) translateY(-3px); }
}
/*standard tractor-bounce web browser animation*/
#keyframes tractor-bounce {
50% { transform: rotate(-5deg) translateY(-3px); }
}