Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

CSS3 Flip functionality (problems with backface-visibility)

CSS3 Flip functionality (problems with backface-visibility)

Problem

I am following a CSS3 tutorial to offer cardflip functionality.

When the user hovers or touches the image, I wish for the image to flip over and display a 2nd image.

So far, I have:

    /* entire container, keeps perspective */
.flip-container {
    perspective: 1000;
}
    /* flip the pane when hovered */
    .flip-container:hover .flipper {
        transform: rotateY(180deg);
        -webkit-transform: rotateY(180deg);
        -moz-transform: rotateY(180deg);
        -o-transform: rotateY(180deg);
    }

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

/* 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;
    -webkit-backface-visibility:hidden; /* Chrome and Safari */
    -moz-backface-visibility:hidden; /* Firefox */
    -ms-backface-visibility:hidden; /* Internet Explorer */
    position: absolute;
    top: 0;
    left: 0;
}

/* front pane, placed above back */
.front {
    z-index: 2;
}

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

http://jsfiddle.net/jP39d/

The problem is that the front image shows the image still despite me setting backface-visibility: hidden;, but reversed. Image 2 is nowhere to be seen!

Reverse of 1st image

Problem courtesy of: Gravy

Solution

Add -webkit-transform-style: preserve-3d; besides transform-style: preserve-3d;. It should work now.

And I guess you want to use -webkit-perspective too because you only used perspective.

So, it's only a prefix issue. Propably you should add -moz and -o too if you want to support them.

Solution courtesy of: Andy

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

CSS3 Flip functionality (problems with backface-visibility)

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×