Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Card Flip in Safari

Tags:

css

card-flip

I'm trying to get a CSS card flip to work on all browsers. I've gotten it to work on everything except Safari. I've used this code:

/* entire container, keeps perspective */
.flip-container {
     perspective: 1000;
     transform-style: preserve-3d;
     display: inline-block;
}

/*  UPDATED! flip the pane when hovered */
.flip-container:hover .back {
     transform: rotateY(0deg);
}
.flip-container:hover .front {
    transform: rotateY(180deg);
    backface-visibility: hidden; 
}

.flip-container, .front {
     width: 250px;
     height: 250px;
}

.flip-container, .back {
     width: 250px;
     height: 250px;
}

 /* flip speed goes here */
 .flipper {
     transition: 0.6s;
     transform-style: preserve-3d;
     position: relative;
}

 /* hide back of pane during swap */
.front, .back {
     backface-visibility: hidden;
     transition: 0.6s;
     transform-style: preserve-3d;
     position: absolute;
     top: 0;
     left: 0;
}

 /*  UPDATED! front pane, placed above back */
.front {
     z-index: 2;
     transform: rotateY(0deg);
}

/* back, initially hidden pane */
.back {
     transform: rotateY(-180deg);
}

But the front flickers in front of the back image on hover before showing the back image.

If you go to my website, I've been playing around with just the president of the company's picture until I get it right before I reformat everyone else. http://www.logomatsdirect.com/our-team/

Any suggestions?

like image 517
Calle Avatar asked Apr 06 '16 12:04

Calle


2 Answers

/* hide back of pane during swap */
.front, .back {
 -webkit-backface-visibility: hidden;
         backface-visibility: hidden;
 -webkit-transition: 0.6s;
         transition: 0.6s;
 -webkit-transform-style: preserve-3d;
         transform-style: preserve-3d;
 position: absolute;
 top: 0;
 left: 0;
 }

 /*  UPDATED! front pane, placed above back */
.front {
 z-index: 2;
 -webkit-transform: rotateY(0deg);
         transform: rotateY(0deg);
}

/* back, initially hidden pane */
.back {
 -webkit-transform: rotateY(-180deg);
         transform: rotateY(-180deg);
}

This should do the trick

like image 181
damiano celent Avatar answered Oct 03 '22 23:10

damiano celent


You can always look up in caniuse.com for browser's supported properties:

http://caniuse.com/#search=css3%203d%20transforms

As stated there, Safari still require a prefix for the backface-visibility property.

like image 34
Alexandre Figueiredo Avatar answered Oct 03 '22 23:10

Alexandre Figueiredo