3D Hover effects
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>3D Book</title> | |
</head> | |
<body> | |
| |
<section> | |
<div class="book"> | |
<img src="cover.jpg" alt="" title=""> | |
</div> | |
</section> | |
| |
</body> | |
</html> | |
| |
<style type="text/css"> | |
*{ | |
margin: 0px; | |
padding: 0px; | |
box-sizing: border-box; | |
} | |
body{ | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
min-height:100vh; | |
} | |
section{ | |
display: flex;justify-content: center; | |
align-items: center; | |
transform-style: preserve-3d; | |
perspective: 1000px; | |
} | |
section .book{ | |
position: relative; | |
width: 383px; | |
height: 567px; | |
box-shadow: 20px 20px 20px rgba(0, 0, 0, 0.2); | |
transform-style: preserve-3d; | |
transition: 5s; | |
} | |
section .book:before{ | |
content: ''; | |
position: absolute; | |
width: 60px; | |
height: 100%; | |
transform-origin: left; | |
background: url(side.jpg); | |
background-position: center; | |
transform: rotateY(90deg); | |
} | |
section .book:after{ | |
content: ''; | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
transform-origin: center; | |
background: url(back.jpg); | |
background-position: center; | |
transform: rotateY(180deg) translateZ(60px); | |
} | |
section .book:hover{ | |
transform: rotateY(350deg); | |
box-shadow: 0px 20px 20px rgba(0, 0, 0, 0.2); | |
} | |
section .book:active{ | |
transform: rotateY(180deg); | |
box-shadow: 0px 20px 20px rgba(0, 0, 0, 0.2); | |
} | |
section .book img{ | |
position: absolute; | |
top: 0px; | |
left: 0px; | |
width: 100%; | |
height: 100%; | |
object-fit: cover; | |
} | |
</style> |
Comments
Post a Comment