A Pen by Anand prabhakar on CodePen.
Created
March 14, 2019 23:29
-
-
Save anandprabhakar0507/18d8b871e7cc07a6a91bdf323b32a4a3 to your computer and use it in GitHub Desktop.
eXVwdQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="iphone-front"></div> | |
<div class="iphone-back"></div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container{ | |
/* How pronounced should the 3D effects be */ | |
perspective: 800px; | |
-webkit-perspective: 800px; | |
background: radial-gradient(#e0e0e0, #aaa); | |
width:480px; | |
height:480px; | |
margin:0 auto; | |
border-radius:6px; | |
position:relative; | |
} | |
.iphone-front, | |
.iphone-back{ | |
/* Enable 3D transforms */ | |
transform-style: preserve-3d; | |
-webkit-transform-style: preserve-3d; | |
/* We are using two separate divs for the front and back of the | |
phone. This will hide the divs when they are flipped, so that the | |
opposite side can be seen: */ | |
backface-visibility: hidden; | |
-webkit-backface-visibility: hidden; | |
width:200px; | |
height:333px; | |
position:absolute; | |
top:50%; | |
left:50%; | |
margin:-166px 0 0 -100px; | |
background:url(https://demo.tutorialzine.com/2013/10/css3-features-you-can-finally-use/assets/img/iphone.png) no-repeat left center; | |
/* Animate the transitions */ | |
transition:0.8s; | |
} | |
.iphone-back{ | |
/* The back side is flipped 180 deg by default */ | |
transform:rotateY(180deg); | |
-webkit-transform:rotateY(180deg); | |
background-position:right center; | |
} | |
.container:hover .iphone-front{ | |
/* When the container is hovered, flip the front side and hide it .. */ | |
transform:rotateY(180deg); | |
-webkit-transform:rotateY(180deg); | |
} | |
.container:hover .iphone-back{ | |
/* .. at the same time flip the back side into visibility */ | |
transform:rotateY(360deg); | |
-webkit-transform:rotateY(360deg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment