Implement CSS3 Custom 3D Flip Animation in IE8+ - html

I have problem to running My CSS3 3D flip Animation in IE Browser. The problem is backface-visibility CSS3 is not work. So if box was flipped, the back box is not showing.
Below is my code
CSS
.flip-container {
-ms-perspective: 1000px;
-webkit-perspective: 1000px;
perspective: 1000px;
position: absolute;
top: 50%;
left: 50%;
margin: -75px 0 0 -75px;
}
.click {
cursor: pointer;
}
.flip-container, .front, .back, .behind {
width: 150px;
height: 150px;
background-color: #d5d5d5;
}
/* flip parent stylesheet */
.flipper-up,
.flipper-right,
.flipper-bottom,
.flipper-left,
.behind {
position: absolute;
top:0;
left: 0;
right:0;
bottom:0;
-ms-transition: 0.8s;
-webkit-transition: 0.8s;
transition: 0.8s;
-ms-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
/* hide back of pane during swap */
.flipper-up .front, .flipper-up .back,
.flipper-right .front, .flipper-right .back,
.flipper-bottom .front, .flipper-bottom .back,
.flipper-left .front, .flipper-left .back {
color: #fff;
font-size: 32px;
text-align: center;
line-height: 150px;
-ms-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom:0;
}
.behind {
z-index: 0;
background-color: purple;
text-align: center;
line-height: 150px;
cursor: pointer;
}
.click {
cursor: pointer;
}
/* Flip to up */
.flipper-up {
z-index: 5;
-ms-transform-origin: top left;
-webkit-transform-origin: top left;
transform-origin: top left;
}
.flipper-up > .front {
/* for firefox 31 */
background-color: red;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-up > .back {
background-color: red;
-ms-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.flip.flipper-up {
-ms-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
/* Flip to right */
.flipper-right {
z-index: 3;
-ms-transform-origin: top right;
-webkit-transform-origin: top right;
transform-origin: top right;
}
.flipper-right > .front {
/* for firefox 31 */
background-color: blue;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-right > .back {
background-color: blue;
-ms-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip.flipper-right {
-ms-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
/* Flip to bottom */
.flipper-bottom {
z-index: 1;
-ms-transform-origin: bottom left;
-webkit-transform-origin: bottom left;
transform-origin: bottom left;
}
.flipper-bottom > .front {
/* for firefox 31 */
background-color: green;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-bottom > .back {
background-color: green;
-ms-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.flip.flipper-bottom {
-ms-transform: rotateX(-180deg);
-webkit-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
/* Flip to left */
.flipper-left {
z-index: 4;
-ms-transform-origin: top left;
-webkit-transform-origin: top left;
transform-origin: top left;
}
.flipper-left > .front {
/* for firefox 31 */
background-color: black;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-left > .back {
background-color: black;
-ms-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip.flipper-left {
-ms-transform: rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.flip {
cursor: default !important;
z-index: 10;
}
HTML
<div class="flip-container">
<div class="click flipper-up">
<div class="front">
1
</div>
<div class="back">
2
</div>
</div>
<div class="click flipper-left">
<div class="front">
3
</div>
<div class="back">
4
</div>
</div>
<div class="click flipper-right">
<div class="front">
5
</div>
<div class="back">
6
</div>
</div>
<div class="click flipper-bottom">
<div class="front">
7
</div>
<div class="back">
8
</div>
</div>
<div class="behind" title="Click here to close the box!">
click to close
</div>
</div>
jQuery
$(document).ready(function() {
$('.click').click(function(){
$(this).addClass('flip');
});
$('.behind').click(function() {
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-bottom").removeClass('flip');
}, 300);
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-right").removeClass('flip');
}, 600);
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-left").removeClass('flip');
}, 900);
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-up").removeClass('flip');
}, 1200);
});
});
http://jsfiddle.net/dhanangpratama/jxz08xva/

Related

CSS Transform RotateX not working in IE11

I have a "promo roller" which is uses CSS animation to rotate a cube, showing only one of the four sides of the cube at any give time. The rotation of the cube shows the next side.
/*-- Animated Promo Roller --*/
#roller {
width: 140px;
height: 28px;
position: absolute;
}
.face1, .face2, .face3, .face4 {
font-size: 16px;
line-height: 28px;
font-weight: bold;
color: #fff;
text-align: center;
width: 140px;
height: 28px;
margin: -8px 0px 10px 157px;
position: absolute;
background: #d71e44; /* Old browsers */
background: -moz-linear-gradient(top, #d71e44 0%, #c11e44 100%); /* FF3.6+ */
background: -moz-gradient(linear, left top, left bottom, color-stop(0%,#d71e44), color-stop(100%,#c11e44)); /* Chrome,Safari4+ */
background: -moz-linear-gradient(top, #d71e44 0%,#c11e44 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #d71e44 0%,#c11e44 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #d71e44 0%,#c11e44 100%); /* IE10+ */
background: linear-gradient(to bottom, #d71e44 0%,#c11e44 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d71e44', endColorstr='#c11e44',GradientType=0 ); /* IE6-9 */
}
#roller .face1 {
transform: translateZ(14px);
}
#roller .face2 {
transform: rotateX(90deg) translateZ(14px);
}
#roller .face3 {
transform: rotateX(180deg) translateZ(14px);
}
#roller .face4 {
transform: rotateX(270deg) translateZ(14px);
}
#keyframes spincube {
from,to { }
0% { transform: rotateX(0deg); }
14% { transform: rotateX(0deg); }
21% { transform: rotateX(-90deg); }
35% { transform: rotateX(-90deg); }
42% { transform: rotateX(-180deg); }
70% { transform: rotateX(-180deg); }
77% { transform: rotateX(-270deg); }
91% { transform: rotateX(-270deg); }
100% { transform: rotateX(-360deg); }
}
#roller {
animation-name: spincube;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 12s;
transform-style: preserve-3d;
transform-origin: 7px 7px 0;
}
<div id="roller">
<div class="face1">WAS R242,900</div>
<div class="face2">NOW R227,900</div>
<div class="face3">SAVE R15,000</div>
<div class="face4">ON PROMO</div>
</div>
The code works perfectly except in Internet Explorer (currently test with IE11), in IE11 the rotational animation works fine. But the transform rotateX and translateZ used to create the cube does not work. So only side of the cube is visible, the other 3 sides are hidden behind it.
Can this be made to work in IE11?
Kind regards
Willem
Better late than never:
IE doesn't support transform-style, see also for example this question (I'm sure there are more than this, but this was the one I found)
You could try to create some css for an effect like this with only 2 sides. With mediaqueries it should be possible to target IE11 only, so you could hide this 3d animation for IE and only show this two sided animation for IE users. Not ideal but better than nothing.
I created a fiddle by copy pasting the code from David Walsh's site, he did a really great work by creating this.
/* simple */
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-ms-perspective: 1000;
perspective: 1000;
-ms-transform: perspective(1000px);
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
border: 1px solid #ccc;
}
/*
.flip-container:hover .flipper, .flip-container.hover .flipper, #flip-toggle.flip .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
filter: FlipH;
-ms-filter: "FlipH";
}
*/
/* START: Accommodating for IE */
.flip-container:hover .back, .flip-container.hover .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.flip-container:hover .front, .flip-container.hover .front {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
/* END: Accommodating for IE */
.flip-container, .front, .back {
width: 320px;
height: 427px;
}
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-ms-transition: 0.6s;
-moz-transition: 0.6s;
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-webkit-transform: rotateY(0deg);
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
-moz-transform: rotateY(0deg);
-o-transition: 0.6s;
-o-transform-style: preserve-3d;
-o-transform: rotateY(0deg);
-ms-transition: 0.6s;
-ms-transform-style: preserve-3d;
-ms-transform: rotateY(0deg);
transition: 0.6s;
transform-style: preserve-3d;
transform: rotateY(0deg);
position: absolute;
top: 0;
left: 0;
}
.front {
-webkit-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
background: lightgreen;
z-index: 2;
}
.back {
background: lightblue;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.front .name {
font-size: 2em;
display: inline-block;
background: rgba(33, 33, 33, 0.9);
color: #f8f8f8;
font-family: Courier;
padding: 5px 10px;
border-radius: 5px;
bottom: 60px;
left: 25%;
position: absolute;
text-shadow: 0.1em 0.1em 0.05em #333;
display: none;
-webkit-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
-ms-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.back-logo {
position: absolute;
top: 40px;
left: 90px;
width: 160px;
height: 117px;
background: url(logo.png) 0 0 no-repeat;
}
.back-title {
font-weight: bold;
color: #00304a;
position: absolute;
top: 180px;
left: 0;
right: 0;
text-align: center;
text-shadow: 0.1em 0.1em 0.05em #acd7e5;
font-family: Courier;
font-size: 22px;
}
.back p {
position: absolute;
bottom: 40px;
left: 0;
right: 0;
text-align: center;
padding: 0 20px;
font-size: 18px;
}
/* vertical */
.vertical.flip-container {
position: relative;
}
.vertical .back {
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
-webkit-transform-origin: 100% 213.5px;
-moz-transform-origin: 100% 213.5px;
-ms-transform-origin: 100% 213.5px;
transform-origin: 100% 213.5px;
}
/*
.vertical.flip-container:hover .flipper {
-webkit-transform: rotateX(-180deg);
-moz-transform: rotateX(-180deg);
-ms-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
*/
/* START: Accommodating for IE */
.vertical.flip-container:hover .back, .vertical.flip-container.hover .back {
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
-o-transform: rotateX(0deg);
-ms-transform: rotateX(0deg);
transform: rotateX(0deg);
}
.vertical.flip-container:hover .front, .vertical.flip-container.hover .front {
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
transform: rotateX(180deg);
}
/* END: Accommodating for IE */
<div class="flip-container vertical" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style='background: #adadad no-repeat 0px 0px;'>
<span class="name">David Walsh</span>
</div>
<div class="back" style="background: rgb(248, 248, 248);">
<div class="back-logo"></div>
<div class="back-title">#davidwalshblog</div>
<p>Mozilla Web Developer, MooTools & jQuery Consultant, MooTools Core Developer, Javascript Fanatic, CSS Tinkerer, PHP Hacker, and web lover.</p>
</div>
</div>
</div>

how to use transform: rotate as hover?

I am trying to rotate 3 divs (cubes) on a hover state but it seems that not every browser can handle this. Only IE Edge without problem.
Firefox works great with the first 2 divs on hover but the cube disappears when hovering on the 3rd.
Chrome starts shaking all the cubes when hovering.
Is there something wrong in my code?
.cube-a,
.cube-b,
.cube-c {
margin-top: 100px;
margin-left: 10px;
float: left;
margin-right: 80px;
width: 100px;
height: 100px;
transform-style: preserve-3d;
transform: rotateX(108deg) rotateY(16deg) rotateZ(192deg);
}
.cube-a .tcface,
.cube-b .tcface,
.cube-c .tcface {
width: 100%;
height: 100%;
position: absolute;
}
.cube-a .cube-a-face {
background-color: #f4e00d;
/* geel */
transform: rotateX(90deg) rotatez(180deg) translateY(-50px) translateZ(50px);
height: 100px;
}
.cube-b .cube-b-face {
background-color: #8db63c;
/* groen */
transform: rotateX(90deg) rotatez(180deg) translateY(-50px) translateZ(50px);
height: 100px;
}
.cube-c .cube-c-face {
background-color: #009de0;
/* blauw */
transform: rotateX(90deg) rotatez(180deg) translateY(-50px) translateZ(50px);
height: 100px;
}
.cube-a .cube-a-right,
.cube-c .cube-c-right {
background-color: #8db63c;
/* groen */
transform: rotateY(-90deg) rotateZ(90deg) translateY(-100px);
transform-origin: 0 0;
width: 100px;
height: 100px;
}
.cube-b .cube-b-right {
background-color: #f4e00d;
/* geel */
transform: rotateY(-90deg) rotateZ(90deg) translateY(-100px);
transform-origin: 0 0;
width: 100px;
height: 100px;
}
.cube-a .cube-a-bottom,
.cube-b .cube-b-bottom {
background-color: #009de0;
/* blauw */
}
.cube-c .cube-c-bottom {
background-color: #f4e00d;
/* geel */
}
.cube-a-bottom,
.cube-b-bottom {
-webkit-transform: rotate(-180deg);
-moz-transform: rotate(-180deg);
-ms-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
}
.cube-a-face,
.cube-a-right,
.cube-a-bottom,
.cube-b-face,
.cube-b-right,
.cube-b-bottom,
.cube-c-face,
.cube-c-right,
.cube-c-bottom {
color: #fff;
text-align: center;
line-height: 100px;
font-size: 92px;
font-weight: 500;
font-family: "Simply Rounded Bold";
}
.cube-a:hover,
.cube-b:hover,
.cube-c:hover {
-webkit-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
-moz-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
-ms-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
-o-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
}
<div class="cube-a">
<div class="tcface cube-a-face">A</div>
<div class="tcface cube-a-right">B</div>
<div class="tcface cube-a-bottom">C</div>
</div>
<div class="cube-b">
<div class="tcface cube-b-face">B</div>
<div class="tcface cube-b-right">A</div>
<div class="tcface cube-b-bottom">C</div>
</div>
<div class="cube-c">
<div class="tcface cube-c-face">C</div>
<div class="tcface cube-c-right">B</div>
<div class="tcface cube-c-bottom">A</div>
</div>
Here is my fiddle:
https://jsfiddle.net/8vuj7peb/100/
Try adding -webkit-transition: all 1s; and transition: all 1s;. This is the transition property, making the transition 1s long.
.cube-a,
.cube-b,
.cube-c {
margin-top: 100px;
margin-left: 10px;
float: left;
margin-right: 80px;
width: 100px;
height: 100px;
transform-style: preserve-3d;
transform: rotateX(108deg) rotateY(16deg) rotateZ(192deg);
-webkit-transition: all 1s; /* Safari */
transition: all 1s;
}
.cube-a .tcface,
.cube-b .tcface,
.cube-c .tcface {
width: 100%;
height: 100%;
position: absolute;
}
.cube-a .cube-a-face {
background-color: #f4e00d;
/* geel */
transform: rotateX(90deg) rotatez(180deg) translateY(-50px) translateZ(50px);
height: 100px;
}
.cube-b .cube-b-face {
background-color: #8db63c;
/* groen */
transform: rotateX(90deg) rotatez(180deg) translateY(-50px) translateZ(50px);
height: 100px;
}
.cube-c .cube-c-face {
background-color: #009de0;
/* blauw */
transform: rotateX(90deg) rotatez(180deg) translateY(-50px) translateZ(50px);
height: 100px;
}
.cube-a .cube-a-right,
.cube-c .cube-c-right {
background-color: #8db63c;
/* groen */
transform: rotateY(-90deg) rotateZ(90deg) translateY(-100px);
transform-origin: 0 0;
width: 100px;
height: 100px;
}
.cube-b .cube-b-right {
background-color: #f4e00d;
/* geel */
transform: rotateY(-90deg) rotateZ(90deg) translateY(-100px);
transform-origin: 0 0;
width: 100px;
height: 100px;
}
.cube-a .cube-a-bottom,
.cube-b .cube-b-bottom {
background-color: #009de0;
/* blauw */
}
.cube-c .cube-c-bottom {
background-color: #f4e00d;
/* geel */
}
.cube-a-bottom,
.cube-b-bottom {
-webkit-transform: rotate(-180deg);
-moz-transform: rotate(-180deg);
-ms-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
}
.cube-a-face,
.cube-a-right,
.cube-a-bottom,
.cube-b-face,
.cube-b-right,
.cube-b-bottom,
.cube-c-face,
.cube-c-right,
.cube-c-bottom {
color: #fff;
text-align: center;
line-height: 100px;
font-size: 92px;
font-weight: 500;
font-family: "Simply Rounded Bold";
}
.cube-a:hover,
.cube-b:hover,
.cube-c:hover {
-webkit-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
-moz-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
-ms-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
-o-transform: rotateX(90deg) rotateY(0deg) rotateZ(180deg);
}
<div class="cube-a">
<div class="tcface cube-a-face">A</div>
<div class="tcface cube-a-right">B</div>
<div class="tcface cube-a-bottom">C</div>
</div>
<div class="cube-b">
<div class="tcface cube-b-face">B</div>
<div class="tcface cube-b-right">A</div>
<div class="tcface cube-b-bottom">C</div>
</div>
<div class="cube-c">
<div class="tcface cube-c-face">C</div>
<div class="tcface cube-c-right">B</div>
<div class="tcface cube-c-bottom">A</div>
</div>

Weird behaviour of CSS-Tesseract (Cube)

I successfully created a cube in a cube, a Tesseract. But for some reason I really can't explain, the cube is moving downwards while the Animation is going on.
If you watch the scrolling bar of your browser, the entire cube is moving downwards.
And yes, of course you can "ignore" this problem by changing the margin of the parent-div-element but that doesn't solve it.
#-webkit-keyframes cube-spin {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(360deg);
transform: rotateY(360deg);
}
}
#keyframes cube-spin {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(360deg);
transform: rotateY(360deg);
}
}
#-webkit-keyframes counter-rot {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(-360deg);
transform: rotateY(-360deg);
}
}
#keyframes counter-rot {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(-360deg);
transform: rotateY(-360deg);
}
}
.cube-wrap {
-webkit-perspective: 800px;
perspective: 800px;
-webkit-perspective-origin: 50% 0%;
perspective-origin: 50% 0%;
}
.outer {
width: 300px !important;
}
.cube {
position: relative;
width: 200px;
margin: 0 auto;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-animation: cube-spin 8s infinite linear;
animation: cube-spin 8s infinite linear;
}
.backendtext {
position: absolute;
width: 200px;
font-size: 35px;
text-align: center;
font-family: sans-serif;
text-transform: uppercase;
-webkit-animation: counter-rot 8s infinite linear;
animation: counter-rot 8s infinite linear;
}
.outer div {
width: 300px;
height: 300px;
background: rgba(255, 116, 0, 0.1);
line-height: 530px;
}
.inner div {
width: 200px;
height: 200px;
background: rgba(153, 69, 0, 0.7);
}
.cube div {
position: absolute;
box-shadow: inset 0 0 30px rgba(125,125,125,0.8);
font-size: 35px;
text-align: center;
font-family: sans-serif;
text-transform: uppercase;
}
.depth div.front-pane {
-webkit-transform: translateY(-100px) translateZ(100px);
transform: translateY(-100px) translateZ(100px);
}
.outer.depth div.front-pane {
-webkit-transform: translateY(-150px) translateZ(150px);
transform: translateY(-150px) translateZ(150px);
}
.depth div.back-pane {
-webkit-transform: translateY(-100px) translateZ(-100px) rotateY(180deg);
transform: translateY(-100px) translateZ(-100px) rotateY(180deg);
}
.outer.depth div.back-pane {
-webkit-transform: translateY(-150px) translateZ(-150px) rotateY(180deg);
transform: translateY(-150px) translateZ(-150px) rotateY(180deg);
}
.depth div.left-pane {
-webkit-transform: translateY(-100px) translateX(100px) rotateY(-270deg);
transform: translateY(-100px) translateX(100px) rotateY(-270deg);
}
.outer.depth div.left-pane {
-webkit-transform: translateY(-150px) translateX(150px) rotateY(-270deg);
transform: translateY(-150px) translateX(150px) rotateY(-270deg);
}
.depth div.right-pane {
-webkit-transform: translateY(-100px) translateX(-100px) rotateY(270deg);
transform: translateY(-100px) translateX(-100px) rotateY(270deg);
}
.outer.depth div.right-pane {
-webkit-transform: translateY(-150px) translateX(-150px) rotateY(270deg);
transform: translateY(-150px) translateX(-150px) rotateY(270deg);
}
.depth div.top-pane {
-webkit-transform: translateY(-200px) rotateX(-90deg);
transform: translateY(-200px) rotateX(-90deg);
}
.outer.depth div.top-pane {
-webkit-transform: translateY(-300px) rotateX(-90deg);
transform: translateY(-300px) rotateX(-90deg);
}
.depth div.bottom-pane {
-webkit-transform: rotateX(90deg);
transform: rotateX(90deg);
}
<div style="height: 300px; margin-top: 400px;">
<div class="cube-wrap">
<div class="cube depth inner">
<a class="backendtext">Backend</a>
<div class="front-pane"></div>
<div class="back-pane"></div>
<div class="top-pane"></div>
<div class="bottom-pane"></div>
<div class="left-pane"></div>
<div class="right-pane"></div>
</div>
<div class="cube depth outer">
<div class="front-pane">Frontend</div>
<div class="back-pane">Frontend</div>
<div class="top-pane"></div>
<div class="bottom-pane"></div>
<div class="left-pane">Frontend</div>
<div class="right-pane">Frontend</div>
</div>
</div>
//EDIT: Works fine on Chrome and Edge. Will try to add prefixes to everything and see if it solves the problem.
//EDIT2: Added Prefixes, still doesn't work on Firefox but does properly on Chrome, Edge etc.
//EDIT3: Set Overflow of the cube-wrapper to hidden but I would still love to know the reason.

Flipping two different images and stopping on hover

The idea is to create an infinite animation on CSS that will show two sides of a card spinning all the time and to stop the animation on hover, revealing only the front and increasing the size 20% with a link to another section.
I am able to flip and grow to the second image on hover, but I seem to be unable to replace the action on a Keyframe animation.
This is what I have so far:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.panel {
width: 300px;
height: 300px;
margin: auto;
position: relative;
}
.card {
width: 100%;
height: 100%;
-o-transition: all .5s;
-ms-transition: all .5s;
-moz-transition: all .5s;
-webkit-transition: all .5s;
transition: all .5s;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0px;
left: 0px;
-webkit-animation: CardFlip 5s infinite;
}
.front {
position: absolute;
top: 0px;
left: 0px;
z-index: 2;
background-image: url('http://placehold.it/300x300/red');
}
.back {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
-webkit-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
transform: rotateY(-180deg);
background-image: url('http://placehold.it/300x300/blue');
}
.panel:hover .front {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.panel:hover .back {
position: absolute;
top: 0px;
left: 0px;
z-index: 2;
-webkit-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-transform: scale(1.2,1.2);
-ms-transform: scale(1.2,1.2);
-moz-transform: scale(1.2,1.2);
transform: scale(1.2,1.2);
}
#-webkit-keyframes CardFlip {
0% {
position: absolute;
top: 0px;
left: 0px;
z-index: 2;
-webkit-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-transform: scale(1.2,1.2);
-ms-transform: scale(1.2,1.2);
-moz-transform: scale(1.2,1.2);
transform: scale(1.2,1.2);
}
100% {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}
</style>
</head>
<body>
<br>
<br>
<div class="panel">
<div class="front card">
</div>
<div class="back card">
</div>
</div>
</body>
I think you need to add backface-visibility: hidden; only to front card.
If you need your animation to have infinite look, you have to have similar 0% and 100% points.
Also, you had missed transform-style: preserve-3d; property.
Also, I've added one more container to avoid animation on cards. I think it's more semantic.
Check out this fiddle: http://jsfiddle.net/nikoloza/2zrk7/
Update
If we add perspective: 1000 to the main container, we'll get real 3d effect. Fiddle: http://jsfiddle.net/nikoloza/2zrk7/1/
Update 2
And if we need only left-to-right flipping we can set 360deg instead of 0deg into 100% point in the animation. Fiddle: http://jsfiddle.net/nikoloza/2zrk7/2/

How to keep Div rotated with css after flip?

I found this tutorial on how to CSS flip a div. You can find the result here. now the thing is, i want to keep the puzzle piece flipped to the back after the hover so the information on the back remains visible. Now i'm not very strong in working with css3. So any help on realizing the desired would be very appreciated!
Here is the code i'm using:
html:
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="puzzel-stuk">
<div class="front" style="background:url('img/puzzel-links-boven-gesloten.png'); background-repeat:no-repeat; width: 323px; height: 429px;"></div>
<div class="back" style="background:url('img/puzzel-links-boven-open.png'); background-repeat:no-repeat; width: 323px; height: 429px; text-align:left;">
<div class="stap-title">
<h1>Stap 1</h1>
</div>
<div class="stap-tekst" style="margin-left:10px;">
Kies een geschikte achtergrond,<br/>
zodat uw brief meer opvalt<br/>
bij uw potentiƫle werkgever.
</div>
</div>
</div>
</div>
</div>
css:
/* simple */
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-ms-perspective: 1000;
perspective: 1000;
-ms-transform: perspective(1000px);
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
}
/*
.flip-container:hover .flipper, .flip-container.hover .flipper, #flip-toggle.flip .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
filter: FlipH;
-ms-filter: "FlipH";
}
*/
/* START: Accommodating for IE */
.flip-container:hover .back, .flip-container.hover .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.flip-container:hover .front, .flip-container.hover .front {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
/* END: Accommodating for IE */
.flip-container, .front, .back {
width: 320px;
height: 427px;
font-size:18px;
display:inline-block;
float:left;
}
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-ms-transition: 0.6s;
-moz-transition: 0.6s;
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
-o-transition: 0.6s;
-o-transform-style: preserve-3d;
-ms-transition: 0.6s;
-ms-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: absolute;
top: 0;
left: 0;
}
.front {
-webkit-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
background: lightgreen;
z-index: 2;
}
.back {
background: lightblue;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.front .name {
font-size: 2em;
display: inline-block;
background: rgba(33, 33, 33, 0.9);
color: #f8f8f8;
font-family: Courier;
padding: 5px 10px;
border-radius: 5px;
bottom: 60px;
left: 25%;
position: absolute;
text-shadow: 0.1em 0.1em 0.05em #333;
display: none;
-webkit-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
-ms-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.back-logo {
position: absolute;
top: 40px;
left: 90px;
width: 160px;
height: 117px;
background: url(logo.png) 0 0 no-repeat;
}
.back-title {
font-weight: bold;
color: #00304a;
position: absolute;
top: 180px;
left: 0;
right: 0;
text-align: center;
text-shadow: 0.1em 0.1em 0.05em #acd7e5;
font-family: Courier;
font-size: 2em;
}
.back p {
position: absolute;
bottom: 40px;
left: 0;
right: 0;
text-align: center;
padding: 0 20px;
}
/* vertical */
.vertical.flip-container {
position: relative;
}
.vertical .back {
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
-webkit-transform-origin: 100% 213.5px;
-moz-transform-origin: 100% 213.5px;
-ms-transform-origin: 100% 213.5px;
transform-origin: 100% 213.5px;
}
/*
.vertical.flip-container:hover .flipper {
-webkit-transform: rotateX(-180deg);
-moz-transform: rotateX(-180deg);
-ms-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
*/
/* START: Accommodating for IE */
.vertical.flip-container:hover .back, .vertical.flip-container.hover .back {
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
-o-transform: rotateX(0deg);
-ms-transform: rotateX(0deg);
transform: rotateX(0deg);
}
.vertical.flip-container:hover .front, .vertical.flip-container.hover .front {
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
transform: rotateX(180deg);
}
/* END: Accommodating for IE */
.stap-title {
width:40%;
margin:0 auto;
margin-top:10px;
display:block;
position:relative;
}
.stap-tekst {
margin-left:10px;
margin-right:10px;
margin-top:20px;
display:block;
width:auto;
position:relative;
}
Add the following jquery code in your file.
$(document).ready(function(){
$('.flip-container').hover(function(){
$(this).addClass('hoverfixed');
});
});
Add the following two Classes in your CSS.
.hoverfixed .back{
-webkit-transform: rotateY(0deg) !important;
-moz-transform: rotateY(0deg) !important;
-o-transform: rotateY(0deg) !important;
-ms-transform: rotateY(0deg) !important;
transform: rotateY(0deg) !important;
}
.hoverfixed .front{
-webkit-transform: rotateY(180deg) !important;
-moz-transform: rotateY(180deg) !important;
-o-transform: rotateY(180deg) !important;
transform: rotateY(180deg) !important;
}