CSS animation with interval and delay only from the second time - css

I want to perform some div animation with intervals. In the first time the animation will play, and then it will be delayed, and then (from the second time) there will be an interval. After that, the animation will be played every X seconds.
This is what I got so far, but the animation starts after delay:
#-webkit-keyframes shake {
10%,
90% {
-webkit-transform: translate3d(-1px, 0, 0);
transform: translate3d(-1px, 0, 0);
}
20%,
80% {
-webkit-transform: translate3d(2px, 0, 0);
transform: translate3d(2px, 0, 0);
}
30%,
50%,
70% {
-webkit-transform: translate3d(-4px, 0, 0);
transform: translate3d(-4px, 0, 0);
}
40%,
60% {
-webkit-transform: translate3d(4px, 0, 0);
transform: translate3d(4px, 0, 0);
}
}
#keyframes shake {
10%,
90% {
-webkit-transform: translate3d(-1px, 0, 0);
transform: translate3d(-1px, 0, 0);
}
20%,
80% {
-webkit-transform: translate3d(2px, 0, 0);
transform: translate3d(2px, 0, 0);
}
30%,
50%,
70% {
-webkit-transform: translate3d(-4px, 0, 0);
transform: translate3d(-4px, 0, 0);
}
40%,
60% {
-webkit-transform: translate3d(4px, 0, 0);
transform: translate3d(4px, 0, 0);
}
}
.error-container {
position: absolute;
left: auto;
border-collapse: separate;
margin: 0;
padding: 2px 10px;
list-style: none;
color: #ffffff;
font-size: 12px;
font-weight: 600;
background: #d9534f;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
display: none;
z-index: 100;
&.active {
display: block;
-webkit-animation: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both 4s infinite;
animation: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both 4s infinite;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 1000px;
perspective: 1000px;
}
}
Is it possible without any JavaScript?Thanks.
Update: here is a demo: [demo][1]

Here you go. What I did is I changed the code so that complete animation ends at 20% and after that it will do nothing till 100%. For more details, visit this link
NOTE: You can clone the webkit to keyframes code as well. I removed it
#-webkit-keyframes shake {
2%,
18% {
-webkit-transform: translate3d(-1px, 0, 0);
transform: translate3d(-1px, 0, 0);
}
4%,
16% {
-webkit-transform: translate3d(2px, 0, 0);
transform: translate3d(2px, 0, 0);
}
6%,
10%,
14% {
-webkit-transform: translate3d(-4px, 0, 0);
transform: translate3d(-4px, 0, 0);
}
8%,
12% {
-webkit-transform: translate3d(4px, 0, 0);
transform: translate3d(4px, 0, 0);
}
100%{
-webkit-transform: translate3d(0px, 0, 0);
transform: translate3d(0px, 0, 0);
}
}
.error-container {
position: absolute;
left: auto;
border-collapse: separate;
margin: 0;
padding: 2px 10px;
list-style: none;
color: #ffffff;
font-size: 12px;
font-weight: 600;
background: #d9534f;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
display: none;
z-index: 100;
&.active {
display: block;
animation: shake 4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 1000px;
perspective: 1000px;
}
}

You can change iteration on animation-duration
here is example
#import url(https://fonts.googleapis.com/css?family=Montserrat:700,400);
* {
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
background: purple;
font-family: 'Montserrat', sans-serif;
}
html, body {
height: 100%;
}
button {
background: #333;
color: #fff;
border-radius: 40px;
padding: 15px 30px;
border: 0;
overflow: hidden;
width: 200px;
transition:
all 1.2s,
border 0.5s 1.2s,
box-shadow 0.3s 1.5s;
white-space: nowrap;
text-indent: 23px;
font-weight: bold;
}
span {
display: inline-block;
transform: translateX(300px);
font-weight: normal;
opacity: 0;
transition:
opacity 0.1s 0.5s,
transform 0.4s 0.5s;
}
button:hover {
text-indent: 0;
background: #55706D;
color: #FFE8A3;
width: 250px;
}
button:hover span {
transform: translateX(0);
opacity: 1;
}
<button>
Animate
<span>After Delay</span>
</button>

Related

How to prevent cards from flipping

I have 4 cards that lay flat and "stand up" on hover however they also flip as they had a front and a back. I only want one-sided cards and I don't know how to stop them flipping. I have removed the html for the back of the card however I can't seem to stop the card flipping in CSS. What do I need to change in my code to stop them flipping?
.card-holder {
width: 90%;
height: 70%;
position: absolute;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: -370em;
text-align: center;
}
div:target .card-face {
animation: flip-2 1s;
animation-fill-mode: forwards;
}
div:target .card-face:before {
animation: shadow-2 1s;
animation-fill-mode: forwards;
}
.card {
display: inline-block;
perspective: 1000px;
position: relative;
margin: 50px;
}
.card:hover .card-face {
animation: flip-2 1s;
animation-fill-mode: forwards;
}
.card:before{
animation: shadow-2 1s;
animation-fill-mode: forwards;
}
.card-face {
display: block;
width: 139px;
height: 250px;
transform-origin: bottom;
animation: flip 1s;
animation-direction: reverse;
animation-fill-mode: forwards;
}
.front-card, .project-img {
width: inherit;
height: inherit;
}
.card:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
transition: all 0.5s;
transform-origin: bottom;
animation: shadow 1s;
animation-direction: normal;
animation-fill-mode: forwards;
}
.card-face {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front-card {
/* backface-visibility: hidden; */
position: absolute;
top: 0;
left: 0;
}
/* .back-card {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
z-index: 2;
} */
.front-card {
transform: rotateY(180deg);
}
#keyframes flip {
0% {
transform: rotateX(50deg) rotateY(0deg);
}
60% {
transform: rotateX(0deg);
}
100% {
transform: rotateX(0deg) rotateY(180deg);
}
}
#keyframes shadow {
0% {
box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5);
transform: rotateX(0deg) translateZ(-60px) scale(0.85);
opacity: 1;
}
60% {
transform: rotateX(95deg) translateZ(-40px) scaleY(0.15) scaleX(0.65) rotateY(0);
box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5);
opacity: 0.25;
}
100% {
transform: rotateX(95deg) translateZ(-40px) scaleY(0.05) scaleX(0.65) rotateY(0);
box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5);
opacity: 0.25;
}
}
/* #keyframes flip-2 {
0% {
transform: rotateX(50deg) rotateY(0deg);}
60% {
transform: rotateX(0deg); }
100% {
transform: rotateX(0deg) rotateY(180deg);}
} */
#keyframes shadow-2 {
0% {
box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5);
transform: rotateX(0deg) translateZ(-60px) scale(0.85);
opacity: 1;}
60% {
transform: rotateX(95deg) translateZ(-40px) scaleY(0.15) scaleX(0.65) rotateY(0);
box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5);
opacity: 0.25;}
100% {
transform: rotateX(95deg) translateZ(-40px) scaleY(0.05) scaleX(0.65) rotateY(0);
box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5);
opacity: 0.25;}
}
<div class="card-holder" id="all-cards">
<div class="card" id="card-1">
<a href="#card-1" class="card-face">
<div class="front-card">
<img class="project-img" src="https://i.imgur.com/0RUrrQF.jpg" alt="Death">
</div>
</a>
</div>
<div class="card" id="card-2">
<a href="#card-2" class="card-face">
<div class="front-card">
<img class="project-img" src="https://i.imgur.com/ulOYmlT.jpg" alt="Death">
</div>
</a>
</div>
</div>
remove this line line 100% {
transform: rotateX(0deg) rotateY(180deg);
} from ...
#keyframes flip {
0% {
transform: rotateX(50deg) rotateY(0deg);
}
60% {
transform: rotateX(0deg);
}
100% {
transform: rotateX(0deg) rotateY(180deg);
}
}

Perfect infinite rotation for ֍ character

Im trying to use this character
֍
in place of a loading spinner.
Here's what I've got so far:
.spinner::after {
animation: rotating 2s linear infinite;
content: "֍";
font-size: 60px;
display: inline-block;
font-weight: normal;
transform-origin: 50% 50%;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
Even though this works, it is not perfect because the rotation does currently not happen around the perfect center of the character despite
transform-origin: 50% 50%;
making it look less than stellar.
Any ideas how to fix this?
I would use a fixed height equal to the font-size then play with line-height until I get it right. Also no need to set transform-origin since by default it's set to center
.spinner::after {
content: "֍";
font-size: 60px;
font-weight: normal;
line-height: 0.8;
display: inline-block;
height: 60px;
animation: rotating 2s linear infinite;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
it happens because a character height and width are not equal...
I tried to increase the height until It does what you want..
and here is the result:
.spinner::after {
animation: rotating 2s linear infinite;
content: "֍";
height: 80px;
font-size: 60px;
display: inline-block;
font-weight: normal;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
Three Properties
line-height: 3;
transform-origin: 50% 54%;
text-align: center;
Demo
.spinner::after {
animation: spin 2s infinite linear;
content: "֍";
font-size: 5em;
display: inline-block;
font-weight: normal;
/* Required */
line-height: 3;
/* Required */
transform-origin: 50% 54%;
/* Required */
text-align: center;
/* Optional for Position */
position: relative;
width: 3em;
top: 0;
}
#keyframes spin {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
You will not get perfect center while rotating rectangle shape but you will get perfect center if its square shape
see demo below
div {
display: inline-block;
width: 100px;
height: 100px;
background-color: brown;
text-align: center;
position: relative;
margin: 10px;
float: left;
}
.spinner0::after {
animation: rotating 2s linear infinite;
content: "֍";
height: 80px;
font-size: 60px;
display: inline-block;
font-weight: normal;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
div > i:before {
content: '';
width: 5px;
height: 5px;
background-color: #000;
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.spinner1::after{
animation: rotating 5s linear infinite;
content: "֍";
font-size: 60px;
line-height: 60px;
display: inline-block;
font-weight: normal;
position: absolute;
left: 50%;
top: 50%;
margin-top: -30px;
margin-left: -22px;
}
.spinner2::after {
animation: rotating 5s linear infinite;
content: "֍";
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
font-size: 60px;
transform: rotate(90deg);
margin-left: 2px;
}
.spinner3::after {
animation: rotating 5s linear infinite;
content: "";
height: 30px;
width: 30px;
font-size: 60px;
line-height: 1;
display: inline-block;
font-weight: normal;
border: 1px solid #000;
position: absolute;
left: 50%;
top: 50%;
margin-top: -15px;
margin-left: -15px;
}
<div>
<i class="spinner1"></i>
</div>
<div>
<i class="spinner2"></i>
</div>
<div>
<i class="spinner3"></i>
</div>
if you still want to rotate rectangular shape/icon then along with rotation you have to adjust its position a bit
hope you got my point here

matrix not equal to translate and rotate combination in css transform animation?

#keyframes gray {
0% { transform: matrix(1, 0, 0, 1, 0, 0) }
100% { transform: matrix(-1, 0, 0, -1, 20, 20) }
}
#keyframes lightblue {
0% { transform: translate(10px, 10px) rotate(0deg) translate(-10px, -10px); }
100% { transform: translate(10px, 10px) rotate(180deg) translate(-10px, -10px); }
}
.gray {
float: left;
margin-left: 50px;
width: 20px;
height: 20px;
background: gray;
transform-origin: 0px 0px;
animation: gray linear 1s infinite;
}
.lightblue {
float: left;
margin-left: 50px;
width: 20px;
height: 20px;
background: lightblue;
transform-origin: 0px 0px;
animation: lightblue linear 1s infinite;
}
<div class="gray"></div>
<div class="lightblue"></div>
As I known
transform: matrix(1, 0, 0, 1, 0, 0);
is equal to
transform: translate(10px, 10px) rotate(0deg) translate(-10px, -10px);
and
transform: matrix(-1, 0, 0, -1, 20, 20)
is equal to
transform: translate(10px, 10px) rotate(180deg) translate(-10px, -10px);
when I use above css rule directly to element, anything works fine.
but after I use above css rule in keyframes, things goes wrong.
the gray element's rotate angle is different from the lightblue one.
I test the code in chrome 71
The issue is how the browser will handle interpolation. Both matrix are fine and they are the same as the transform defined but the interpolation between both is not the same.
Use forwards instead of infinite to see that both will start and end at the same state:
#keyframes gray {
0% { transform: matrix(1, 0, 0, 1, 0, 0) }
100% { transform: matrix(-1, 0, 0, -1, 20, 20) }
}
#keyframes lightblue {
0% { transform: translate(10px, 10px) rotate(0deg) translate(-10px, -10px); }
100% { transform: translate(10px, 10px) rotate(180deg) translate(-10px, -10px); }
}
.gray {
float: left;
margin-left: 50px;
width: 20px;
height: 20px;
background: gray;
transform-origin: 0px 0px;
animation: gray linear 2s 0.5s forwards;
border-right:2px solid;
}
.lightblue {
float: left;
margin-left: 50px;
width: 20px;
height: 20px;
background: lightblue;
transform-origin: 0px 0px;
animation: lightblue linear 2s 0.5s forwards;
border-right:2px solid;
}
<div class="gray"></div>
<div class="lightblue"></div>
Basically, the matrix will first get decomposed into transformation then will get interpolated. so the first one matrix(1, 0, 0, 1, 0, 0) which is the indentity will get transformed to a null transformation (ex scale(1,1) or rotate(0)) and not translate(10px, 10px) rotate(0deg) translate(-10px, -10px) like you may think. then the second one matrix(-1, 0, 0, -1, 20, 20) can be transformed to scale(-1,-1) translate(-20px,-20px). Again it won't be translate(10px, 10px) rotate(180deg) translate(-10px, -10px).
Now it's clear that the interpolation (the intermediate states) will not be the same for both animation. This is due to the fact that the browser will not use the same transformations you used to define the matrix. In theory, There is a infinite number of combination and the browser will use it's own algorithm to find the one he will use which will not necessarily be the one you defined.
You can check this link for more details : https://drafts.csswg.org/css-transforms/#interpolation-of-transforms
Here is an example how we can make both the same:
#keyframes gray {
0% { transform: matrix(1, 0, 0, 1, 0, 0) }
100% { transform: matrix(-1, 0, 0, -1, 20, 20) }
}
#keyframes lightblue {
0% { transform: scale(1,1) }
100% { transform:scale(-1,-1) translate(-20px, -20px) ; }
}
.gray {
float: left;
margin-left: 50px;
width: 20px;
height: 20px;
background: gray;
transform-origin: 0px 0px;
animation: gray linear 2s 0.5s infinite;
border-right:2px solid;
}
.lightblue {
float: left;
margin-left: 50px;
width: 20px;
height: 20px;
background: lightblue;
transform-origin: 0px 0px;
animation: lightblue linear 2s 0.5s infinite;
border-right:2px solid;
}
<div class="gray"></div>
<div class="lightblue"></div>

Hover effect works only in firefox

any idea why this doesn't work in any other browsers apart from Firefox?
I have tried chrome, safari and IE (obviously, it won't work, because nothing does with IE).
thanks!
the SASS code is below, in case it helps:
#import url(http://fonts.googleapis.com/css?family=Bree+Serif);
$w: 200;
$h: 180;
$duration: 300ms;
$timing-fn: ease;
$turquoise: #1ABC9C;
$wet-asphalt: #34495E;
$midnight-blue: #2C3E50;
$clouds: #ECF0F1;
* {box-sizing: border-box}
body {background-color: #fff}
h1 {
margin: 0 auto 5px;
text-align: center;
}
h3 {font-family: 'Bree Serif', serif}
.container {
width: 840px;
margin: 0 auto;
}
header {
font-family: 'Bree Serif', serif;
text-align: center;
margin: 50px 0 25px;
color: $wet-asphalt;
p {
margin: 0;
color: transparentize($wet-asphalt, .6);
}
}
ul {
padding: 0;
margin: 0 0 50px;
&:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
}
li {
position: relative;
overflow: hidden;
border-radius: 4px;
list-style: none;
float: left;
width: #{$w}px;
height: #{$h}px;
margin: 5px;
padding: 0;
perspective: 500px;
a {
display: inline-block;
vertical-align: top;
text-decoration: none;
border-radius: 4px;
}
h3 {
margin: 0;
font-size: 16px;
color: transparentize(#fff, .1);
}
p {
font-size: 12px;
line-height: 1.5;
color: transparentize(#fff, .2);
}
.normal {
width: 100%;
height: 100%;
background-color: $clouds;
color: transparentize($wet-asphalt, .4);
box-shadow: inset 0 2px 20px darken($clouds, 2);
text-align: center;
font-size: 50px;
line-height: #{$h}px;
svg {
pointer-events: none;
width: 50px;
path {
fill: transparentize($wet-asphalt, .8);
}
}
}
.info {
width: 100%;
height: 100%;
padding: 20px;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
border-radius: 4px;
pointer-events: none;
background-color: transparentize($turquoise, .1);
transform: rotate3d(1, 0, 0, 90deg);
}
}
.in-top .info {
transform-origin: 50% 0%;
animation: in-top $duration $timing-fn 0ms 1 forwards;
}
.in-right .info {
transform-origin: 100% 0%;
animation: in-right $duration $timing-fn 0ms 1 forwards;
}
.in-bottom .info {
transform-origin: 50% 100%;
animation: in-bottom $duration $timing-fn 0ms 1 forwards;
}
.in-left .info {
transform-origin: 0% 0%;
animation: in-left $duration $timing-fn 0ms 1 forwards;
}
.out-top .info {
transform-origin: 50% 0%;
animation: out-top $duration $timing-fn 0ms 1 forwards;
}
.out-right .info {
transform-origin: 100% 50%;
animation: out-right $duration $timing-fn 0ms 1 forwards;
}
.out-bottom .info {
transform-origin: 50% 100%;
animation: out-bottom $duration $timing-fn 0ms 1 forwards;
}
.out-left .info {
transform-origin: 0% 0%;
animation: out-left $duration $timing-fn 0ms 1 forwards;
}
#keyframes in-top {
from {transform: rotate3d(-1, 0, 0, 90deg);}
to {transform: rotate3d(0, 0, 0, 0deg);}}
#keyframes in-right {
from {transform: rotate3d(0, -1, 0, 90deg);}
to {transform: rotate3d(0, 0, 0, 0deg);}}
#keyframes in-bottom {
from {transform: rotate3d(1, 0, 0, 90deg);}
to {transform: rotate3d(0, 0, 0, 0deg);}}
#keyframes in-left {
from {transform: rotate3d(0, 1, 0, 90deg);}
to {transform: rotate3d(0, 0, 0, 0deg);}}
#keyframes out-top {
from {transform: rotate3d(0, 0, 0, 0deg);}
to {transform: rotate3d(-1, 0, 0, 102deg);}}
#keyframes out-right {
from {transform: rotate3d(0, 0, 0, 0deg);}
to {transform: rotate3d(0, -1, 0, 102deg);}}
#keyframes out-bottom {
from {transform: rotate3d(0, 0, 0, 0deg);}
to {transform: rotate3d(1, 0, 0, 101deg);}}
#keyframes out-left {
from {transform: rotate3d(0, 0, 0, 0deg);}
to {transform: rotate3d(0, 1, 0, 102deg);}}

CSS Transform hover not consistent in chrome

I'm trying to make a menu with css3 rotations. Here is an example.
http://jsfiddle.net/5Bg7P/
When a person hovers the square rotates 90 degrees around the x-axis, then when a user clicks it, it rotates an additional 5 degrees to 95 degrees. In chrome, sometimes after it rotates, and i click on it, it goes back to 0 degrees as if the mouse left the item even though it didn't. It happens more often if you let the menu item finish spinning and then only click on it.
Any advice would be appreciated.
#menu .menuItem {
position: relative;
float: left;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transform: translate3d(0, 0, -50px);
transform: translate3d(0, 0, -50px);
-webkit-transition: .5s;
transition: .5s;
width: 120px;
height: 50px;
opacity: .6;
cursor: pointer;
}
#menu .menuItem:hover {
-webkit-transform: rotateX(90deg);
transform: rotateX(90deg);
margin-top: 1px;
}
#menu .menuItem:active {
-webkit-transform: rotateX(95deg);
transform: rotateX(95deg);
margin-top: 1px;
}
#menu .menuItem div {
position: absolute;
width: 120px;
height: 50px;
border: 1px solid #f2f2f2;
background: #848488;
}
#menu .menuItem .front,
#menu .menuItem .bottom {
text-align: center;
height: 50px;
line-height: 50px;
color: #f2f2f2;
letter-spacing: 1px;
font-size: 18px;
}
#menu .menuItem .front {
-webkit-transform: translate3d(0, 0, 25px);
transform: translate3d(0, 0, 25px);
}
#menu .menuItem .back {
-webkit-transform: translate3d(0, 0, -25px);
transform: translate3d(0, 0, -25px);
/* box-shadow: 0px 0px 40px 7px #b9c9d0; */
}
#menu .menuItem .top {
-webkit-transform: rotateX(90deg) translate3d(0, 0, 25px);
transform: rotateX(90deg) translate3d(0, 0, 25px);
}
#menu .menuItem .bottom {
-webkit-transform: rotateX(-90deg) translate3d(0, 0, 25px);
transform: rotateX(-90deg) translate3d(0, 0, 25px);
}
#menu .menuItem .right {
-webkit-transform: rotateY(90deg) translate3d(0, 0, 50px);
transform: rotateY(90deg) translate3d(0, 0, 50px);
height: 50px;
width: 50px;
left: 25px;
}
#menu .menuItem .left {
-webkit-transform: rotateY(-90deg) translate3d(0, 0, 50px);
transform: rotateY(-90deg) translate3d(0, 0, 50px);
height: 50px;
width: 50px;
left: 25px;
}
I think that's a problem about the hover state being activated in the base element or the child element.
I have changed a little bit how the hover and the transforms work, and now it works ok (or at least it works ok in my tests)
CSS
#menu {
position: relative;
z-index: 1;
float: left;
font-family: helvetica;
}
#menu .menuItem {
position: relative;
float: left;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transition: .5s;
transition: .5s;
width: 120px;
height: 50px;
opacity: .6;
cursor: pointer;
}
#menu .menuItem:active {
-webkit-transform: rotateX(5deg);
transform: rotateX(5deg);
margin-top: 1px;
}
#menu .menuItem div {
position: absolute;
width: 120px;
height: 50px;
border: 1px solid #f2f2f2;
background: #848488;
text-align: center;
line-height: 50px;
letter-spacing: 1px;
font-size: 18px;
margin-top: 1px;
transition: .5s;
}
#menu .menuItem .front {
-webkit-transform: translate3d(0, 0, 25px);
transform: translate3d(0, 0, 25px);
}
#menu .menuItem .bottom {
-webkit-transform: rotateX(-90deg) translate3d(0, 0, 25px);
transform: rotateX(-90deg) translate3d(0, 0, 25px);
}
#menu .menuItem:hover .front {
-webkit-transform: rotateX(90deg) translate3d(0, 0, 25px);
transform: rotateX(90deg) translate3d(0, 0, 25px);
}
#menu .menuItem:hover .bottom {
-webkit-transform: translate3d(0, 0, 25px);
transform: translate3d(0, 0, 25px);
}
fiddle
updated fiddle
The transtion between
transform: rotateX(90deg) translate3d(0, 0, 25px);
and
transform: translate3d(0, 0, 25px);
is not a perfect rotation, but the interpolation between the 2 movements.
To get a pure rotation, the other state must have matching properties:
transform: rotateX(0deg) translate3d(0, 0, 25px);

Resources