css transitions - CSS3 - 3D Card flip animation without using click events -
this question has answer here:
- flip 3d card css 1 answer
i'm new in css3, , interested in 3d animation it. have question , hope can me. there way make card flip effect without using click events? have searched lot not generate results little experience. please, me?
you can css-transitions
, no javascript @ all. using :target
css attribute detect state of card
css
a { display: block; margin-bottom: 10px; padding: 10px; width: 135px; background: red; border: 1px solid black; border-radius: 10px; color: white; text-transform: uppercase; text-decoration: none; } a.unflip { display: none; } div.card { position: relative; } img { position: absolute; width: 190px; height: 265px; -webkit-transition: 1s; -moz-transition: 1s; -o-transition: 1s; -ms-transition: 1s; transition: 1s; } img.front { z-index: 1; } img.back, div#flip:target img.front { -webkit-transform: rotatey(-180deg); -moz-transform: rotatey(-180deg); -o-transform: rotatey(-180deg); -ms-transform: rotatey(-180deg); transform: rotatey(-180deg); z-index: 0; } div#flip:target a.flip { display: none; } div#flip:target a.unflip { display: block; } div#flip:target img.back { -webkit-transform: rotatey(0deg); -moz-transform: rotatey(0deg); -o-transform: rotatey(0deg); -ms-transform: rotatey(0deg); transform: rotatey(0deg); z-index: 1; }
html :
<div class='card' id='flip'> <a href='#flip' class='flip'>flip card</a> <a href='#unflip' class='unflip'>flip card</a> <img src='https://encrypted-tbn2.gstatic.com/images?q=tbn:and9gcrznro98qangrbnmuumctzqnmse0deuqxelgwi2zpskymjd-lqn' class='front' /> <img src='https://encrypted-tbn0.gstatic.com/images?q=tbn:and9gcqswcvrsqzzfqzympsfvgdombadbqc2b7a1i88kda2p52k3vn0y7w' class='back' /> </div>
demo here : http://jsbin.com/emolev/1/edit
Comments
Post a Comment