Skip to content

Commit 02daec9

Browse files
committed
add 3D product card
1 parent bfd1ea3 commit 02daec9

File tree

5 files changed

+194
-2
lines changed

5 files changed

+194
-2
lines changed

Diff for: 58-3D product card/images/adidas.png

618 KB
Loading

Diff for: 58-3D product card/index.html

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!-- Awesome 3D ANIMATION Javascript Tutorial! by Simo Edwin - Dev Ed (2020)
2+
see: https://www.youtube.com/watch?v=XK7T3mY1V-w -->
3+
4+
<!DOCTYPE html>
5+
<html lang="en">
6+
<head>
7+
<meta charset="UTF-8" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9+
<link rel="stylesheet" href="style.css" />
10+
<title>3D Product Card</title>
11+
</head>
12+
<body>
13+
<div class="container">
14+
<div class="card">
15+
<div class="sneaker">
16+
<div class="circle"></div>
17+
<img src="images/adidas.png" alt="adidas" />
18+
</div>
19+
<div class="info">
20+
<h1 class="title">Adidas ZX</h1>
21+
<h3>
22+
FUTURE-READY TRAINERS WITH WRAPPED BOOST FOR EXCEPTION COMFORT.
23+
</h3>
24+
<div class="sizes">
25+
<button>39</button>
26+
<button>40</button>
27+
<button class="active">42</button>
28+
<button>44</button>
29+
</div>
30+
<div class="purchase">
31+
<button>Purchase</button>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
<script src="script.js"></script>
37+
</body>
38+
</html>

Diff for: 58-3D product card/script.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Movement Animation to happen
2+
const card = document.querySelector(".card");
3+
const container = document.querySelector(".container");
4+
5+
// Items
6+
const title = document.querySelector(".title");
7+
const sneaker = document.querySelector(".sneaker img");
8+
const purchase = document.querySelector(".purchase");
9+
const description = document.querySelector(".info h3");
10+
const sizes = document.querySelector(".sizes");
11+
12+
// Moving animation event
13+
container.addEventListener("mousemove", (e) => {
14+
let xAxis = (window.innerWidth / 2 - e.pageX) / 25;
15+
let yAxis = (window.innerHeight / 2 - e.pageY) / 25;
16+
card.style.transform = `rotateX(${yAxis}deg) rotateY(${xAxis}deg)`;
17+
});
18+
19+
// Animate In
20+
container.addEventListener("mouseenter", (e) => {
21+
card.style.transition = "none";
22+
// Popout
23+
title.style.transform = "translateZ(150px)";
24+
sneaker.style.transform = "translateZ(200px) rotateZ(-45deg)";
25+
description.style.transform = "translateZ(125px)";
26+
sizes.style.transform = "translateZ(100px)";
27+
purchase.style.transform = "translateZ(75px)";
28+
});
29+
30+
// Animate Out
31+
container.addEventListener("mouseleave", (e) => {
32+
card.style.transition = "all 0.5s ease";
33+
card.style.transform = `rotateX(0deg) rotateY(0deg)`;
34+
//Popback
35+
title.style.transform = "translateZ(0px)";
36+
sneaker.style.transform = "translateZ(0) rotateZ(0deg)";
37+
description.style.transform = "translateZ(0px)";
38+
sizes.style.transform = "translateZ(0px)";
39+
purchase.style.transform = "translateZ(0px)";
40+
});

Diff for: 58-3D product card/style.css

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap");
2+
3+
* {
4+
box-sizing: border-box;
5+
margin: 0;
6+
padding: 0;
7+
}
8+
9+
body {
10+
font-family: "Poppins", sans-serif;
11+
display: flex;
12+
align-items: center;
13+
justify-content: center;
14+
min-height: 100vh;
15+
overflow: hidden;
16+
perspective: 1000px;
17+
}
18+
19+
.container {
20+
width: 50%;
21+
display: flex;
22+
justify-content: center;
23+
align-items: center;
24+
}
25+
26+
.card {
27+
min-height: 80vh;
28+
width: 35rem;
29+
box-shadow: 0px 20px 20px rgba(0, 0, 0, 0.2), 0px 0px 50px rgba(0, 0, 0, 0.2);
30+
border-radius: 30px;
31+
padding: 0rem 5rem;
32+
transform-style: preserve-3d;
33+
}
34+
35+
.sneaker {
36+
min-height: 35vh;
37+
display: flex;
38+
justify-content: center;
39+
align-items: center;
40+
position: relative;
41+
}
42+
43+
.sneaker img {
44+
width: 20rem;
45+
z-index: 2;
46+
transition: all 0.75s ease-out;
47+
}
48+
49+
.circle {
50+
width: 15rem;
51+
height: 15rem;
52+
background: linear-gradient(
53+
to right,
54+
rgba(245, 70, 66, 0.75),
55+
rgba(8, 83, 156, 0.75)
56+
);
57+
position: absolute;
58+
z-index: 1;
59+
border-radius: 50%;
60+
}
61+
62+
.info h1 {
63+
font-size: 3rem;
64+
transition: all 0.75s ease-out;
65+
}
66+
67+
.info h3 {
68+
font-size: 1.3rem;
69+
padding: 2rem 0rem;
70+
color: #585858;
71+
font-weight: lighter;
72+
transition: all 0.75s ease-out;
73+
}
74+
75+
.sizes {
76+
display: flex;
77+
justify-content: space-between;
78+
transition: all 0.75s ease-out;
79+
}
80+
81+
.sizes button {
82+
padding: 0.5rem 2rem;
83+
background: none;
84+
border: none;
85+
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2);
86+
border-radius: 30px;
87+
cursor: pointer;
88+
font-weight: bold;
89+
font-family: inherit;
90+
color: #585858;
91+
}
92+
93+
button.active {
94+
color: white;
95+
background-color: #585858;
96+
}
97+
98+
.purchase {
99+
margin-top: 3rem;
100+
transition: all 0.75s ease-out;
101+
}
102+
103+
.purchase button {
104+
width: 100%;
105+
padding: 1rem 0rem;
106+
background: #f54642;
107+
border: none;
108+
color: white;
109+
cursor: pointer;
110+
border-radius: 30px;
111+
font-weight: bolder;
112+
font-family: inherit;
113+
}

Diff for: README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
| 54 | [CSS Loaders](https://github.com/solygambas/html-css-fifty-projects/tree/master/54-css%20loaders) | [Live Demo](https://codepen.io/solygambas/full/QWGdgaZ) |
6363
| 55 | [Glass Dashboard](https://github.com/solygambas/html-css-fifty-projects/tree/master/55-glass%20dashboard) | [Live Demo](https://codepen.io/solygambas/full/oNYpQMo) |
6464
| 56 | [Image Comparison Slider](https://github.com/solygambas/html-css-fifty-projects/tree/master/56-image%20comparison%20slider) | [Live Demo](https://codepen.io/solygambas/full/RwoMLYW) |
65-
| 57 | [Parallax background with SVG](https://github.com/solygambas/html-css-fifty-projects/tree/master/57-parallax%20background%20svg) | [Live Demo](https://codepen.io/solygambas/full/vYyjjbz) |
65+
| 57 | [Parallax Background with SVG](https://github.com/solygambas/html-css-fifty-projects/tree/master/57-parallax%20background%20svg) | [Live Demo](https://codepen.io/solygambas/full/vYyjjbz) |
66+
| 58 | [3D Product Card](https://github.com/solygambas/html-css-fifty-projects/tree/master/58-3D%20product%20card) | [Live Demo](https://codepen.io/solygambas/full/wvoXWPq) |
6667

67-
Based on [50 Projects In 50 Days - HTML, CSS & JavaScript](https://www.udemy.com/course/50-projects-50-days/) by Brad Traversy (2020).
68+
Based on [50 Projects In 50 Days - HTML, CSS & JavaScript](https://www.udemy.com/course/50-projects-50-days/) by Brad Traversy (2020) and various YouTube tutorials.

0 commit comments

Comments
 (0)