Skip to content

Commit 23cec43

Browse files
author
Secretariat
committed
3D Image Hover
1 parent 07dc061 commit 23cec43

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed

3D Card Hover/img/1.png

1.86 MB
Loading

3D Card Hover/img/2.png

1.26 MB
Loading

3D Card Hover/img/back.jpg

527 KB
Loading

3D Card Hover/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>3D Card Hover</title>
6+
<link rel="stylesheet" href="style.css" />
7+
</head>
8+
<body>
9+
<figure>
10+
<img src="img/2.png" alt="Necromancer" />
11+
<figcaption>The Necro</figcaption>
12+
</figure>
13+
<figure>
14+
<img src="img/1.png" alt="Druid" />
15+
<figcaption>The Druid</figcaption>
16+
</figure>
17+
</body>
18+
</html>

3D Card Hover/style.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@font-face {
2+
font-family: "Exoct";
3+
src: url("https://assets.codepen.io/1480814/films.EXH_____.ttf");
4+
}
5+
6+
body {
7+
margin: 0;
8+
min-height: 100vh;
9+
display: grid;
10+
grid-auto-flow: column;
11+
grid-auto-columns: min(230px, 35vmin);
12+
place-content: end center;
13+
gap: 50px;
14+
background: linear-gradient(#0000, rgb(50 50 50 / 88%)),
15+
url("img/back.jpg") top/cover;
16+
}
17+
18+
figure {
19+
width: 100%;
20+
aspect-ratio: 1;
21+
margin: 0 0 60px;
22+
padding: 5px 20px 0;
23+
box-sizing: border-box;
24+
display: grid;
25+
grid-template-rows: 100%;
26+
cursor: pointer;
27+
position: relative;
28+
filter: drop-shadow(0 0 20px rgb(0 0 0/50%));
29+
}
30+
31+
figure:before {
32+
content: "";
33+
position: absolute;
34+
z-index: -1;
35+
inset: 0;
36+
background: top/cover;
37+
transform-origin: bottom;
38+
filter: brightness(0.9);
39+
transition: 0.5s;
40+
}
41+
42+
figure:before {
43+
background-image: url(https://assets.codepen.io/1480814/necro-back.jpg);
44+
}
45+
46+
figure + figure:before {
47+
background-image: url(https://assets.codepen.io/1480814/druid-bac.jpg);
48+
}
49+
50+
figure:hover::before {
51+
filter: brightness(0.3);
52+
transform: perspective(500px) rotateX(60deg);
53+
}
54+
55+
figcaption {
56+
grid-area: 1/1;
57+
width: calc(100% + 40px);
58+
font-family: Exoct;
59+
color: white;
60+
font-size: min(32px, 5vmin);
61+
text-align: center;
62+
place-self: end center;
63+
transform: perspective(500px) translateY(100%) rotateX(-90deg);
64+
backface-visibility: hidden;
65+
transform-origin: top;
66+
background: #000;
67+
transition: 0.5s;
68+
}
69+
70+
figure:hover figcaption {
71+
transform: perspective(500px) translateY(100%) rotateX(-30deg);
72+
}
73+
74+
img {
75+
grid-area: 1/1;
76+
width: 100%;
77+
height: 100%;
78+
object-fit: cover;
79+
object-position: top;
80+
filter: contrast(0.8) brightness(0.7);
81+
place-self: end center;
82+
transition: 0.5s;
83+
}
84+
85+
figure:hover img {
86+
width: 130%;
87+
height: 255%;
88+
filter: contrast(1);
89+
}

0 commit comments

Comments
 (0)