I'm trying to create a simple CSS Flip effect on some images and put links on the backside... however, the links work in FireFox, but not Chrome or Safari.
I've tried many different methods, but I can't seem to figure it out.
/* Artists Flip */
.rsp-img-center {
margin: 0 auto;
}
.front img {
border-radius: 50%;
width: 120px;
height: 120px;
background-color: #000;
}
#f1_container {
position: relative;
margin: 10px auto;
width: 200px;
height: 175px;
-webkit-perspective: 1000;
-moz-perspective: 1000;
-o-perspective: 1000;
perspective: 1000;
}
#f1_card {
width: 200px;
height: 175px;
position: relative;
transition: 0.6s;
transform-style: preserve-3d;
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
}
#f1_container:hover #f1_card {
position: relative;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg) scale(1);
-moz-transform: rotateY(180deg);
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
z-index: 100;
clear: both;
top: 0;
}
.face {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
}
.face.back {
display: inline-block;
z-index: 500;
position: absolute;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
color: white;
text-align: center;
background-image: url("http://beta2.thrivemusic.com/wp-content/uploads/2014/07/flip_back.png");
background-attachment:local;
position: relative;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
-moz-backface-visibility: hidden;
}
.face.back a{
z-index: 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999;
}
.front {
background-color: #000000;
}
.back {
background-attachment:local;
background-position:center;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
Here's the codepen URL: http://codepen.io/samkimdesign/pen/tAvDn
Any help would be greatly appreciated, thanks!
Just in case, have a look at my jsfiddle
css3 and html :
#card {
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-perspective: 1000;
-moz-perspective: 1000;
-ms-perspective: 1000;
-o-perspective: 1000;
perspective: 1000;
width: 250px;
height: 250px;
position: relative;
}
.back, .front {
position: absolute;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: -webkit-transform 1s ease-in;
-moz-transition: -moz-transform 1s ease-in;
-ms-transition: -ms-transform 1s ease-in;
-o-transition: -ms-transform 1s ease-in;
transition: transform 1s ease-in;
width: 100%;
height: 100%;
padding: 20px;
font-family: Helvetica, Arial, sans-serif;
color: #000;
font-weight: bold;
box-shadow: inset 0px 0px 20px rgba(0,0,0,0.4);
border-radius: 4px;
}
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
background: #bde;
overflow: hidden;
}
.front {
background: #fde;
}
#card-container {
display: inline-block;
text-align: justify;
}
#card-container:target .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
transform: rotateY(0deg);
}
#card-container:target .front {
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
<div id="card-container">
<div id="card">
<div class="back">This is the back of the card
<br/>Go to front
</div>
<div class="front">This is the front of the card
<br/>Go to back
</div>
</div>
</div>
Related
I've successfully gotten two images to flip like a card when hovering over. Using transition and transform-style. It works except on mobile (iPhone; chrome and safari). What am I doing wrong? Any guidance very much appreciated.
I've reviewed previous posts on StackOverflow but what I've found did not help my situation.
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<img src="./resources/images/green.jpg" alt="" style="width:421px;height:552px">
</div>
<div class="flip-box-back">
<img src="./resources/images/brown.jpg" alt="" style="width:421px;height:552px">
</div>
</div>
</div>
.flip-box {
background-color: transparent;
width: 421px;
height: 552px;
border: 0px;
-webkit-perspective: 1000px;
-moz-perspective: 1000px;
-ms-perspective: 1000px;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.flip-box:hover .flip-box-inner {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
transform-style: preserve-3d;
}
.flip-box-front, .flip-box-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
-ms-backface-visibility: hidden;
}
.flip-box-front {
transform-style: preserve-3d;
}
.flip-box-back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
transform-style: preserve-3d;
}
I expected the card to flip back and forth on mobile but it only transitions once.
Not answering the direct question, but maybe try the CSS from DavidWalsh.name (with prefixes).
/* entire container, keeps perspective */
.flip-box {
-webkit-perspective: 1000px;
perspective: 1000px;
}
/* flip the pane when hovered */
.flip-box-inner:hover .flipper, .flip-box-inner.hover .flipper {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip-box, .flip-box-front, .flip-box-back {
width: 421px;
height: 552px;
}
/* flip speed goes here */
.flip-box-inner {
-webkit-transition: 0.6s;
transition: 0.6s;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.flip-box-front, .flip-box-back {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
/* front pane, placed above back */
.flip-box-front {
z-index: 2;
/* for firefox 31 */
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.flip-box-back {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
I have a parent div with a class of .card and it has to children div, that rotates in opposite directions when their parent is hovered over to create a flipping card. If you hover over it and wait until the transition finishes it works fine, however if you hover over it then move the mouse of before the animation finishes the div with a class of .front rotates in the opposite direction, why and is there a way to fix this? In addition if you move the mouse on and off multiple times both children start turning at different times even though they have the same trigger- why?
https://jsfiddle.net/8pktgqpu/15/
.card,.front,.back{
width: 100px;
height: 160px;
margin: 1px;
}
.card{
position: relative;
}
.front{
background-color: red;
transform: perspective(400px) rotatey(0deg);
backface-visibility: hidden;
transition: transform 1s ease-in-out 0s;
}
.back{
backface-visibility: hidden;
transform: perspective(400px) rotatey(180deg);
background-color: blue;
transition: transform 1s ease-in-out 0s;
position: absolute;
top: 0;
}
.card:hover .front{
transform: rotatey(-180deg);
}
.card:hover .back{
transform: rotatey(0deg);
}
Add a div and use perspective and transform-style: preserve-3d; to get it
below an example
.flip {
width: 300px;
height: 500px;
perspective: 1000px;
}
.flip_box {
width: 300px;
height: 500px;
position: relative;
transition: all 0.4s linear;
-webkit-transition: all 0.4s linear;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d
}
.front, .back {
position: absolute;
width: 300px;
height: 500px;
top: 0px;
left: 0px;
border: 1px solid #666;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}
.front {
color: red;
font-size: 16px;
}
.back {
color: blue;
font-size: 18px;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
}
.flip:hover .flip_box {
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
}
<div class="flip">
<div class="flip_box">
<div class="front">
Hello
</div>
<div class="back">
Bye
</div>
</div>
</div>
Try this...
.card-container {
perspective: 1000px;
}
.card-container:hover .card, .card-container.hover .card {
transform: rotateY(180deg);
}
.card-container, .front, .back {
width: 100px;
height: 160px;
margin: 1px;
}
.card {
transition: 1s ease-in-out 0s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
z-index: 2;
transform: rotateY(0deg);
background-color: red;
}
.back {
transform: rotateY(180deg);
background-color: blue;
}
<div class="card-container">
<div class="card">
<div class="front">
front
</div>
<div class="back">
back
</div>
</div>
</div>
I have a dashboard in that I am using CSS3 flip animations,the flip animations are working fine in windows but when comes to chrome on Mac OS X the flip animation is flickering when I am hovering on that DIV.Please provide me some fix.
Thanks.
CSS:
Here the problem is only with 'back face' when I am hovering on that div it is flickering.
#f1_container {
position: relative;
width: 100%;
z-index: 1;
margin-bottom: 20px;
display: inline-block;
}
#f1_container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-ms-perspective: 1000;
-o-perspective: 1000;
perspective: 1000;
}
#f1_card {
width: 100%;
height: 100%;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transition: 1.5s ease-in-out;
-moz-transition: 1.5s ease-in-out;
-ms-transition: 1.5s ease-in-out;
-o-transition: 1.5s ease-in-out;
transition: 1.5s ease-in-out;
background-color: white;
}
#f1_container:hover #f1_card {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.face {
position: relative;
width: 100%;
height: 100%;
-moz-transform-style: preserve-3d;
-moz-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
top: 0;
}
.face.back {
display: block;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
transform: rotateY(-180deg);
box-sizing: border-box;
color: white;
text-align: center;
position: absolute;
-moz-transform-style: preserve-3d;
-moz-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-moz-transform: rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
}
.no-flick{
-webkit-transform:translate3d(0,0,0);
-moz-transform:translate3d(0,0,0);
-ms-transform:translate3d(0,0,0);
-o-transform:translate3d(0,0,0);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
I experienced the same issue using Chrome 57 on OSX. Upon flipping the card, the back would show briefly and then disappear to white.
My solution was to set background-color: white; on the front and back instead of the flip container. Not 100% sure why the background color is an issue but it flips correctly now with no flicker! :)
I have a card with something on the back, and I'm y-rotating the card +/- 180 deg:
http://jsfiddle.net/s46t6cem/1/
#back {
transform: rotateY(180deg);
}
.flipped-right {
transform: rotateY(180deg);
}
.flipped-left {
transform: rotateY(-180deg);
}
In the jsfiddle basic example, both flips work fine. However, in my application, flipping right works, but when I flip left, I can see the back as it's moving (it flickers though, which is odd), but then I can't see the back when it stops moving. I can see it if I change the original #back rotation to 181 deg.
and then
I can't figure out what's different between the fiddle and my app that might be causing this. How can I further diagnose this?
I dont know how to debug this kind of things. But maybe you need to add some x-browser propierty:
-webkit -moz -o -ms. I have used this code in other project, try it, it worked for me (not for IE)
<style>
.flip-container {
position: relative;
height: 100%;
-webkit-perspective: 800;
-moz-perspective: 800;
-o-perspective: 800;
-ms-perspective: 800;
perspective: 800;
padding: 0;
}
.flip {
height: 100%;
width: 100%;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
.flip-container:hover .flip {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.side {
position: absolute;
height: 100%;
width: 100%;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
}
.flip .front {
height: 100%;
width: 100%;
}
.flip .back {
display: block;
height: 100%;
width: 100%;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
</style>
<div class="flip-container">
<div class="flip">
<div class="side front">
a
</div>
<div class="side back">
b
</div>
</div>
</div>
Thank you #mknadler, I took background: white off of the #card and it works.
jsfiddle of the problem with the space of the flip
this is code from david walsh's blog
There is a space between the two elements, even though no margin or padding seem to be specified. Someone got a clue where this space is coming from?
It is visible in two places
HTML
<div class="flipcardscontainer">
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style="background: red 0 0 no-repeat">
</div>
<div class="back">
This is ’ title2 </div>
</div>
</div>
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style="background: red 0 0 no-repeat">
</div>
<div class="back">
This is ’ post title 1 </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;
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 {
height: 130px;
width: 130px;
display: inline-block;
}
.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;
}
.flipcardscontainer{
width: 520px;
background-color: blue;
}
/* 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 {
height: 130px;
width: 130px;
display: inline-block;
margin-bottom: -7px;
}
.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;
}
.flipcardscontainer{
width: 520px;
background-color: blue;
}
try this
<div class="flipcardscontainer">
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style="background: red 0 0 no-repeat">
</div>
<div class="back">
This is lukas’ title2 </div>
</div>
</div><div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style="background: red 0 0 no-repeat">
</div>
<div class="back">
This is lukas’ post title 1 </div>
</div>
</div>
</div>
this is my fiddle : http://jsfiddle.net/ayiem999/UwShL/
http://jsfiddle.net/ayiem999/5jMnE/1/ <--- new fiddle without any line