Category : Css | Author : Chtiwi Malek | First posted : 7/21/2014 | Updated : 9/7/2014
Tags : css3, tutorial, flip, cards, animation, plugin, effects, hover
CSS3 3D Flipping Cards Effect

CSS3 3D Flipping Cards Effect

In this tutorial we'll create a cross-browser 3D flipping card only using css3. The user will be able to flip a card and reveal its reverse side on hover or switch sides programmatically using JavaScript.

Here's an example illustrating the use of this css3 technique :

HTML Markup :

The html structure is simple, each card have a front and a back side, wrapped inside a container :
<div class="flipcard h">
    <div class="front">
      This is the front side
    </div>
    <div class="back">
	  This is the back side
    </div>
</div>
The div with class name 'flipcard' will be the main container, inside it we will place two divs representing the two sides of the card (front and back), these two divs will actually flip when the parent div is hovered.

Just add a class named 'v' or 'h' to the main div to define the flipping direction: horizontal or vertical.

CSS Code :

.flipcard {
  position: relative;
  width: 220px;
  height: 160px;
  perspective: 500px;
}
.flipcard.v:hover .front, .flipcard.v.flip .front{
  transform: rotateX(180deg);
}
.flipcard.v:hover .back, .flipcard.v.flip .back{
  transform: rotateX(0deg);
}
.flipcard.v .back{
  transform: rotateX(-180deg);
}
.flipcard.h:hover .front, .flipcard.h.flip .front{
  transform: rotateY(180deg);
}
.flipcard.h:hover .back, .flipcard.h.flip .back{
  transform: rotateY(0deg);
}
.flipcard.h .back{
  transform: rotateY(-180deg);
}
.flipcard .front, .flipcard .back
{
  position:absolute;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  transition: all 0.5s ease-in;
  color: white;
  background-color: #000;
  padding: 10px;
  backface-visibility: hidden;
}
When the main div is hovered, the two inside divs will be rotated 180° with the css3 ‘transform’ property. The flip duration will be 0.5 second for this example.

The front and back divs have an absolute position, they will be superposed and the back side (div) will be rotated initially and will use the css3 'backface-visibility' property to hide its backside (which became front after the initial rotation).

Programmatically flip a card :

To flip one or many cards programmatically via a button click or another javascript event, just add/remove the class 'flip' to their main div.
 
here’s the JavaScript line to do that :
document.querySelector('#cardId').classList.toggle('flip');
// or using jQuery
// $("#cardId").toggleClass("flip");

Browser Support

This technique rely on CSS3, it has been tested on IE10, IE11, Firefox, Google chrome and should work on most modern browsers.
 
Feel free to comment if you have any question or improvement.
About the author :
Malek Chtiwi is the man behind Codicode.com
34 years old full stack developer.
Loves technology; but also likes design, photography and composing music.
Comments & Opinions :
IE workaround
I like your code, does not depend on the preserve-3d keyword which is not supported by internet explorer 10 and 11
- by Joe on 8/2/2014
Positioning.
Hello Malek,
I would like to put more than 1 fliping element however if I use absolute position they will both be located in the same place and if i use relative positioning then the back side of the flipcard is in different spot than front and it makes the site looks ugly. Could u tell me how to make it look like it is in the three examples at the top of this site?
- by Mateusz on 8/11/2014
Hi, this can be done by setting the main container to position:relative and the cards (front and back) to position:absolute. I've updated the code, thanks for pointing that out.
- by Chtiwi Malek on 8/13/2014
With a button click
Your code is really helpful for me. I would like to know how do I perform the same animation on a button click. I can't make it work. Can you please help me.
 
- by josh on 8/14/2014
thanks
thanks a lot
its working properly thank you so much bro 
- by nirav jethava on 9/2/2014
the animators
Thanks Yu are genius...
- by domashy on 10/3/2014
How Can I Click the Card to Flip?
Hey Malek,

This is a really great tutorial. How can I just make the card Flip on click without the hover effect?
I added a button so that it would flip on the click of the button, but it still flips when I hover over it.

Any suggestions would really help!

- Logan
- by Logan on 10/27/2014
How Can I Click the Card to Flip?
Hey Malek,

This is a really great tutorial. How can I just make the card Flip on click without the hover effect?
I added a button so that it would flip on the click of the button, but it still flips when I hover over it.

Any suggestions would really help!

- Logan
- by Logan on 10/28/2014
it's not working on chrome
hi,
please help with a info: how do i need to save this files html and css to make it work? i have save it like index.html for htmls and style.css for the css code and when i open the index file it shows me "This is the front side" and "This is the back side" ! 
anyone, help please.

thanks in advance
- by Ewgor on 11/3/2014
On Click
hey, how can i add a click button for flip effect?
- by Max on 11/28/2014
Thank you!
I was searching and searching for a simple flip effect without any cross browser issues and this was the ticket.  Thank you so much!
- by David on 1/29/2015
flipped tile in ipad
i like your code. it looks great. is this code working on ipad. if it not work means how to over come or alrenate the code. pls help me.
- by manoj on 2/10/2015
Thanks
Thanks for this I am using this to base before and after photos on :)
- by Jennie on 2/11/2015
working in IE
An example working in IE is visible here www.seeveeze.com
- by amine on 3/18/2015
brilliant! Thanks
This is brilliant. Thank you for sharing this awesome piece code! :) :) :)
- by DE on 6/19/2015
Does exactly as it states
Fantastic. Thank you. Simple yet brilliant
- by Jeff on 6/22/2015
Help for touch screen
This works great, but can you help me with overcoming the hover issue on touch screens using the methoad above for card flipping transitions.
 
- by Jeff on 6/23/2015
nice one!
I found another example first, at http://davidwalsh.name/css-flip - but I needed one which didn't use div attribute (his way uses "ontouchstart"). Nice one, saved me! =D
- by Johnny C on 6/26/2015
Vertical Flip
Here is the complete solution to flip a div vertically 
https://uisnip.appspot.com/?share=/s/9tjc3v4b5wt6mcm/VerticalFlip-2?dl=0
- by Sumit Kapoor on 8/19/2015
Vertical Flip
Here is the complete solution to flip a div vertically 
https://uisnip.appspot.com/?share=/s/9tjc3v4b5wt6mcm/VerticalFlip-2?dl=0
- by Sumit Kapoor on 8/19/2015
It's not working on safari
Good one!! :)  but not working in safari :(
- by Deepu on 12/2/2016
yueqin

cheap jordan shoes

 

swarovski sale

 

bercrombie

 

yeezy shoes

 

polo ralph lauren outlet online

 

louboutin outlet

 

louis vuitton

 

longchamp pliage

 

coach handbags outlet

 

coach outlet store online

 

adidas running shoes

 

yeezy boost

 

fitflops

 

coach factory outlet store

 

true religion jeans

 

coach outlet canada

 

kate spade handbags

 

air max outlet

 

michael kors bags

 

michael kors

 

jimmy choo shoes

 

ed hardy uk

 

air jordans

 

coach outlet store online clearance

 

christian louboutin outlet

 

jordan retro

 

christian louboutin outlet

 

swarovski uk

 

birkenstock outlet

 

burberry sale

 

michael kors outlet clearance

 

tory burch outlet online

 

michael kors purses

 

michael kors outlet online

 

louis vuitton outlet online

 

marc jacobs

 

marc jacobs outlet

 

adidas sneakers

 

coach factory outlet

 

jordan femmes pas cher

 

kate spade outlet store

 

discount oakley sunglasses

 

michael kors outlet store

 

ralph lauren sale

 

jerseys cheap

 

polo ralph lauren outlet online

 

pandora charms sale

 

michael kors outlet clearance

 

beats wireless headphones

 

kd 8 shoes

 

birkenstocks

 

coach outlet online

 

coach factory outlet online

 

nike sneakers

 

coach factory outlet

 

michael kors outlet clearance

 

tommy hilfiger windbreaker

 

christian louboutin

 

cheap rolex watches

 

fitflops

 

sac louis vuitton

 

kate spade

 

kate spade outlet online

 

toms outlet

 

louis vuitton purses

 

timberland boots outle

 

nike uk

 

coach outlet online

 

fitflop shoes

 

gucci

 

cheap oakley sunglasses

 

coach factory outlet

 

air max 90

 

coach outlet online

 

michael kors handbags clearance

 

ralph lauren uk

 

polo ralph lauren outlet online

 

celine outlet online

 

nike outlet store

 

kate spade outlet

 

discount oakley sunglasses

 

michael kors

 

moncler jackets

 

rolex replica watches

 

rangers jerseys

 

birkin handbags

 

coach outlet online

 

louis vuitton factory outlet

 

tory burch sale

 

ralph lauren outlet online

 

birkenstock outlet

 

christian louboutin outlet

 

true religion jeans outlet

 

michael kors

 

cheap oakley sunglasses

 

yeezy boost 350

 

longchamp handbags

 

cheap oakley sunglasses

 

red bottom shoes for women

 

michael kors outlet clearance

 

coach factory outlet online

 

cardinals jerseys

 

ray bans

 

ghd straighteners sale

 

fendi bags

 

nike outlet

 

coach outlet store

 

adidas outlet store

 

cheap oakley sunglasses

 

yeezy boost 350 v2

 

adidas sneakers

 

red bottom

 

tods shoes

 

mulberry uk

 

pandora bracelet

 

thunder jerseys

 

sac longchamp

 

cheap nfl jerseys

 

christian louboutin uk

 

ralph lauren

 

true religion

 

tommy hilfiger outlet

 

ralph lauren outlet online

 

oakley sunglasses outlet

 

longchamp bags

 

coach outlet store online

 

eahawks jerseys

 

yeezy boost

 

louboutin shoes

 

jordan uk

 

coach factory outlet online

 

birkenstock

 

tods outlet

 

coach factory outlet

 

louboutin outlet

 

michael kors

 

hermes bags

 

pandora charms sale

 

rolex replica watches for sale

 

polo ralph lauren

 

rolex watches

 

coach outlet online

 

michael kors

 

pandora charms

 

louis vuitton factory outlet

 

mont blanc pens

 

phillies jerseys

 

ed hardy outlet

 

michael kors outlet online

 

fred perry polo shirts

 

ralph lauren outlet

 

longchamp handbags

 

michael kors outlet store

 

nike free run

 

michael kors outlet clearance

 

cheap oakley sunglasses

 

michael kors outlet online

 

nike sneakers

 

49ers jerseys

 

polo ralph lauren outlet

 

nike flyknit

 

rolex watches

 

toms outlet store

 

ralph lauren outlet online

 

cheap ray ban sunglasses

 

cheap jordan shoes

 

coach outlet online

 

fitflops sale

 

adidas yeezy boost

 

michael kors outlet

 

gucci bags

 

true religion jeans outlet

 

fitflops sale clearance

 

longchamp sale

 

adidas yeezy boost

 

louis vuitton outlet online

 

birkenstock shoes

 

michael kors outlet canada

 

swarovski crystals

 

ray ban sunglasses sale

 

cowboys jerseys

 

ralph lauren sale clearance uk

 

mbt

 

polo ralph lauren outlet online

 

nike tn pas cher

 

ghd hair

 

air max

 

pandora jewellery

 

coach factory outlet

 

fred perry polo shirts

 

michael kors outlet store

 

michael kors

 

longchamp bags

 

nfl jerseys wholesale

 

adidas nmd r1

 

michael kors bags

 

lakers jerseys

 

ray ban sunglasses outlet

 

longchamp soldes

 

moncler uk

 

air max 90

 

christian louboutin sale

 

coach outlet online

 

yeezy boost

 

beats headphones

 

cheap nike shoes

 

coach outlet store

 

adidas nmd runner

 

true religion sale

 

rockets jerseys

 

pandora jewelry store

 

coach outlet store online

 

louis vuitton handbags

 

nike air max 95

 

curry shoes

 

mlb jerseys

 

michael kors outlet online

 

oakley sunglasses wholesale

 

michael kors outlet online

 

dolce and gabbana outlet online

 

michael kors outlet canada

 

prada outlet online

 

michael kors outlet store

 

coach outlet online

 

fit flops

 

discount oakley sunglasses

 

adidas nmd runner

 

pandora charms outlet

 

moncler jackets

 

chaussures louboutin

 

texans jerseys

 

lebron shoes

 

red sox jerseys

 

michael kors

 

parada bags

 

air max shoes

 

nike blazer low pas cher

 

pandora jewelry outlet

 

purs jerseys

 

oakley sunglasses outlet

 

dodgers jerseys

 

michael kors bags

 

versace

 

mont blanc pen

 

kate spade purses

 

michael kors bags

 

michael kors outlet store

 

moncler outlet online

 

moncler uk

 

adidas nmd r1

 

louboutin outlet

 

cheap rolex replica watches

 

air max 90

 

fitflops clearance

 

discount oakley sunglasses

 

levis outlet

 

cheap air max

 

adidas nmd r1

 

coach outlet online

 

longchamp handbags

 

yeezy shoes

 

jordan shoes

 

fitflops sale

 

pandora charms outlet

 

ralph lauren uk

 

discount nike shoes

 

coach factory outlet

 

mont blanc pen

 

true religion outlet online

 

adidas superstar shoes

 

nike outlet

 

ralph lauren outlet online

 

adidas uk

 

true religion outlet store

 

nike store

 

polo ralph lauren outlet online

 

true religion outlet store

 

coach factory outlet

 

nike outlet store online

 

birkenstock uk

 

coach outlet online

 

fitflop shoes

 

coach factory outlet online

 

nike cortez classic

 

ray bans

 

michael kors outlet store

 

moncler coats

 

adidas outlet online

 

michael kors uk

 

christian louboutin shoes

 

adidas nmd runner

 

christian louboutin

 

adidas nmd r1

 

louboutin shoes

 

hermes outlet online

 

cubs jerseys

 

polo ralph lauren

 

coach factory outlet online

 

nmd adidas

 

giants jerseys

 

pandora charms

 

kate spade outlet online

 

nfl jerseys wholesale

 

jordans

 

warriors jerseys

 

polo ralph lauren

 

true religion jeans outlet

 

polo ralph lauren

 

birkenstock outlet

 

coach factory outlet

 

gucci outlet online

 

cheap nike sneakers

 

vans outlet

 

mulberry outlet uk

 

cheap jerseys

 

cheap oakley sunglasses

 

ray ban sale

 

white sox jerseys

 

toms outlet

 

coach purses

 

valentino outlet

 

mulberry

 

coach factory outlet online

 

kate spade bags

 

nike roshe shoes

 

mlb jerseys

 

ray ban sunglasses discount

 

coach factory outlet online

 

michael kors outlet online

 

mlb jerseys

 

coach outlet online

 

coach outlet online

 

polo ralph lauren

 

chi flat iron

 

louis vuitton outlet online

 

mulberry handbags

 

adidas superstars

 

fitflop

 

burberry outlet online

 

nfl jerseys cheap

 

kate spade bags

 

coach outlet online

 

christian louboutin sale

 

louboutin outlet

 

ray ban glasses

 

cavaliers jerseys

 

ray ban sunglasses outlet

 

polo ralph lauren outlet

 

michael kors handbags outlet

 

michael kors outlet store

 

nike air max 95

 

yeezy boost 350

 

louboutin pas cher

 

discount oakley sunglasses

 

sac longchamp

 

cheap jordan shoes

 

air jordans

 

michael kors outlet online

 

michael kors outlet store

 

pandora jewelry

 

james shoes

 

coach outlet

 

michael kors handbags outlet

 

nike free 4.0 flyknit

 

true religion uk

 

adidas outlet online

 

michael kors uk

 

pandora outlet

 

yeezy shoes

 

toms

 

michael kors outlet online

 

cheap jordan shoes

 

coach outlet online

 

eltics jerseys

 

polo ralph lauren pas cher

 

polo ralph lauren outlet

 

ralph lauren sale

 

mlb jerseys

 

ralph lauren outlet online

 

longchamp bag

 

adidas yeezy boost

 

polo ralph lauren outlet

 

christian louboutin pas cher

 

coach outlet online

 

hollister clothing

 

pandora charms sale clearance

 

coach outlet store online

 

coach outlet store

 

cheap jerseys

 

michael kors handbags outlet

 

wireless beats headphones

 

kate spade uk

 

coach outlet online

 

oakley sunglasses cheap

 

longchamp outlet store

 

coach outlet online

 

pandora jewellery

 

adidas yeezy boost 350

 

adidas nmd runner

 

true religion jeans outlet

 

pandora charms sale clearance

 

adidas

 

cheap oakley sunglasses

 

coach outlet online

 

toms shoes

 

kate spade outlet online

 

celine handbags

 

yeezy boost 350

 

pandora charms sale clearance

 

mulberry bags

 

coach factory outlet online

 

pandora

 

cheap oakley sunglasses

 

gucci bags

 

beats by dre

 

coach outlet store

 

toms

 

michael kors outlet

 

adidas sneakers

 

coach factory outlet online

 

sac louis vuitton pas cher

 

moncler pas cher

 

patriots jerseys

 

ray ban sunglasses discount

 

longchamp bag

 

michael kors outlet store

 

gucci handbags outlet

 

coach outlet online

 

coach outlet online

 

nike air huarache

 

montblanc pens

 

chaussures louboutin

 

michael kors outlet online

 

coach factory outlet online

 

kate spade outlet online

 

oakley sunglasses outlet

 

nike air force

 

michael kors

 

kd shoes

 

michael kors outlet clearance

 

pandora uk

 

birkenstocks

 

nfl jerseys

 

fred perry shirts

 

oakley sunglasses on sale

 

pandora charms outlet

 

montblanc

 

chaussure louboutin pas cher

 

louis vuitton outlet store

 

rolex replica watches for sale

 

abercrombie outlet

 

pandora jewelry

 

adidas outlet store

 

gucci

 

yeezy boost 350

 

ralph lauren

 

coach outlet

 

red bottom

 

pandora jewelry outlet

 

bulls jerseys

 

coach outlet store

 

coach factory outlet online

 

gucci handbags outlet

 

hollister clothing store

 

polo ralph lauren outlet online

 

nike free run flyknit

 

fit flops

 

fit flops

 

adidas trainers

 

michael kors bags

 

coach outlet store online

 

burberry outlet

 

tigers jerseys

 

air max

 

fitflops sale

 

mulberry uk

 

gucci outlet online

 

longchamps

 

nike roshe one

 

coach factory outlet online

 

tory burch outlet online

 

michael kors outlet store

 

christian louboutin shoes

 

adidas

 

cheap jordan shoes

 

adidas ultra boost

 

coach outlet online

 

ed hardy store

 

broncos jerseys

 

toms

 

louis vuitton outlet store

 

ralph lauren outlet

 

coach factory outlet online

 

vans store

 

nike outlet online

 

ralph lauren sale clearance uk

 

longchamp bags

 

yankees jerseys

 

hollister kids

 

nike air max

 

kobe bryant shoes

 

coach outlet store online

 

michael kors purse

 

ralph lauren outlet

 

adidas trainers

 

adidas superstar trainers

 

fake rolex watches

 

packers jerseys

 

coach outlet online

 

yeezy boost

 

ray ban glasses

 

ed hardy clothing

 

ralph lauren sale

 

nike outlet store

 

true religion jeans outlet

 

pandora charms sale clearance

 

cheap nfl jerseys

 

coach outlet online

 

christian louboutin outlet

 

michael kors outlet store

 

adidas store

 

pandora charms

 

fitflops sale clearance

 

michael kors handbags

 

heat jerseys

 

cheap ray ban sunglasses

 

adidas yeezy boost

 

pandora charms

 

coach outlet online

 

jordan shoes

 

polo ralph lauren outlet

 

gucci borse

 

air max

 

louis vuitton bags

 

louis vuitton outlet online

 

coach factory outlet online

 

hermes bags

 

cheap jordans for sale

 

yeezy 350 boost

 

polo ralph lauren outle

 

red bottom heels

 

adidas superstars

 

michael kors outlet online

 

harden shoes

 

michael kors outlet online

 

nike outlet store

- by 20170419 yueqin on 4/19/2017
Leave a Comment:
Name :
Email : * will not be shown
Title :
Comment :


» Member access