├── app.js
├── img
├── black.png
├── blue.png
├── green.png
├── logo.png
├── orange.png
└── red.png
├── index.html
└── style.css
/app.js:
--------------------------------------------------------------------------------
1 | const sizes = document.querySelectorAll('.size');
2 | const colors = document.querySelectorAll('.color');
3 | const shoes = document.querySelectorAll('.shoe');
4 | const gradients = document.querySelectorAll('.gradient');
5 | const shoeBg = document.querySelector('.shoeBackground');
6 |
7 | let prevColor = "blue";
8 | let animationEnd = true;
9 |
10 | function changeSize(){
11 | sizes.forEach(size => size.classList.remove('active'));
12 | this.classList.add('active');
13 | }
14 |
15 | function changeColor(){
16 | if(!animationEnd) return;
17 | let primary = this.getAttribute('primary');
18 | let color = this.getAttribute('color');
19 | let shoe = document.querySelector(`.shoe[color="${color}"]`);
20 | let gradient = document.querySelector(`.gradient[color="${color}"]`);
21 | let prevGradient = document.querySelector(`.gradient[color="${prevColor}"]`);
22 |
23 | if(color == prevColor) return;
24 |
25 | colors.forEach(c => c.classList.remove('active'));
26 | this.classList.add('active');
27 |
28 | document.documentElement.style.setProperty('--primary', primary);
29 |
30 | shoes.forEach(s => s.classList.remove('show'));
31 | shoe.classList.add('show');
32 |
33 | gradients.forEach(g => g.classList.remove('first', 'second'));
34 | gradient.classList.add('first');
35 | prevGradient.classList.add('second');
36 |
37 | prevColor = color;
38 | animationEnd = false;
39 |
40 | gradient.addEventListener('animationend', () => {
41 | animationEnd = true;
42 | })
43 | }
44 |
45 | sizes.forEach(size => size.addEventListener('click', changeSize));
46 | colors.forEach(c => c.addEventListener('click', changeColor));
47 |
48 | let x = window.matchMedia("(max-width: 1000px)");
49 |
50 | function changeHeight(){
51 | if(x.matches){
52 | let shoeHeight = shoes[0].offsetHeight;
53 | shoeBg.style.height = `${shoeHeight * 0.9}px`;
54 | }
55 | else{
56 | shoeBg.style.height = "475px";
57 | }
58 | }
59 |
60 | changeHeight();
61 |
62 | window.addEventListener('resize', changeHeight);
--------------------------------------------------------------------------------
/img/black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sefyudem/Product-Card-Using-HTML-CSS/a37f6826c865321a2f6df41702c4fda08b8a59d1/img/black.png
--------------------------------------------------------------------------------
/img/blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sefyudem/Product-Card-Using-HTML-CSS/a37f6826c865321a2f6df41702c4fda08b8a59d1/img/blue.png
--------------------------------------------------------------------------------
/img/green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sefyudem/Product-Card-Using-HTML-CSS/a37f6826c865321a2f6df41702c4fda08b8a59d1/img/green.png
--------------------------------------------------------------------------------
/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sefyudem/Product-Card-Using-HTML-CSS/a37f6826c865321a2f6df41702c4fda08b8a59d1/img/logo.png
--------------------------------------------------------------------------------
/img/orange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sefyudem/Product-Card-Using-HTML-CSS/a37f6826c865321a2f6df41702c4fda08b8a59d1/img/orange.png
--------------------------------------------------------------------------------
/img/red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sefyudem/Product-Card-Using-HTML-CSS/a37f6826c865321a2f6df41702c4fda08b8a59d1/img/red.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Product Card
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
nike
24 |

25 |
26 |
27 |

28 |

29 |

30 |

31 |

32 |
33 |
34 |
35 |
36 |
37 |
Nike Zoom KD 12
38 | new
39 |
40 |
Men's running shoes
41 |
42 |
43 |
Product Info
44 |
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's.
45 |
46 |
47 |
Color
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
size
58 |
59 | 7
60 | 8
61 | 9
62 | 10
63 | 11
64 |
65 |
66 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/style.css:
--------------------------------------------------------------------------------
1 | :root{
2 | --primary: #2175f5;
3 | }
4 |
5 | *{
6 | margin: 0;
7 | padding: 0;
8 | box-sizing: border-box;
9 | font-family: 'Poppins', sans-serif;
10 | }
11 |
12 | body{
13 | background-color: #efefef;
14 | }
15 |
16 | .container{
17 | min-height: 100vh;
18 | display: flex;
19 | justify-content: center;
20 | align-items: center;
21 | padding: 40px;
22 | overflow: hidden;
23 | }
24 |
25 | .card{
26 | display: flex;
27 | justify-content: center;
28 | align-items: center;
29 | width: 860px;
30 | }
31 |
32 | .shoeBackground{
33 | position: relative;
34 | width: 50%;
35 | height: 475px;
36 | box-shadow: -15px 0 35px rgba(0, 0, 0, 0.1),
37 | 0 -15px 35px rgba(0, 0, 0, 0.1),
38 | 0 15px 35px rgba(0, 0, 0, 0.1);
39 | transition: .5s;
40 | }
41 |
42 | .gradients{
43 | position: absolute;
44 | width: 100%;
45 | height: 100%;
46 | left: 0;
47 | top: 0;
48 | }
49 |
50 | .gradient{
51 | position: absolute;
52 | width: 100%;
53 | height: 100%;
54 | left: 0;
55 | top: 0;
56 | z-index: -2;
57 | }
58 |
59 | .first{
60 | z-index: 0;
61 | animation: 1s width ease;
62 | }
63 |
64 | @keyframes width{
65 | from{
66 | width: 0%;
67 | }
68 | to{
69 | width: 100%;
70 | }
71 | }
72 |
73 | .second{
74 | z-index: -1;
75 | }
76 |
77 | .gradient[color="blue"]{
78 | background-image: linear-gradient(45deg, #0136af, #22abfa);
79 | }
80 |
81 | .gradient[color="red"]{
82 | background-image: linear-gradient(45deg, #d62926, #ee625f);
83 | }
84 |
85 | .gradient[color="green"]{
86 | background-image: linear-gradient(45deg, #11998e, #1ce669);
87 | }
88 |
89 | .gradient[color="orange"]{
90 | background-image: linear-gradient(45deg, #fc4a1a, #f7b733);
91 | }
92 |
93 | .gradient[color="black"]{
94 | background-image: linear-gradient(45deg, #111, #666);
95 | }
96 |
97 | .logo{
98 | position: absolute;
99 | width: 100px;
100 | left: 20px;
101 | top: 20px;
102 | }
103 |
104 | .share{
105 | position: absolute;
106 | top: 15px;
107 | right: 15px;
108 | background-color: #fff;
109 | width: 50px;
110 | height: 50px;
111 | border-radius: 50%;
112 | text-align: center;
113 | font-size: 1.3rem;
114 | text-decoration: none;
115 | color: var(--primary);
116 | transition: .5s;
117 | }
118 |
119 | .share:hover{
120 | transform: scale(1.1);
121 | }
122 |
123 | .share i{
124 | line-height: 50px;
125 | }
126 |
127 | .nike{
128 | position: absolute;
129 | top: 85px;
130 | left: 15px;
131 | font-size: 11rem;
132 | text-transform: uppercase;
133 | line-height: .9;
134 | color: #fff;
135 | opacity: .1;
136 | }
137 |
138 | .shoe{
139 | position: absolute;
140 | width: 140%;
141 | opacity: 0;
142 | bottom: 0;
143 | right: 0;
144 | transform: rotate(-20deg);
145 | transition: .5s;
146 | }
147 |
148 | .shoe.show{
149 | opacity: 1;
150 | }
151 |
152 | .info{
153 | width: 50%;
154 | background-color: #fff;
155 | z-index: 1;
156 | padding: 35px 40px;
157 | box-shadow: 15px 0 35px rgba(0, 0, 0, 0.1),
158 | 0 -15px 35px rgba(0, 0, 0, 0.1),
159 | 0 15px 35px rgba(0, 0, 0, 0.1);
160 | }
161 |
162 | .shoeName{
163 | padding: 0 0 10px 0;
164 | }
165 |
166 | .shoeName div{
167 | display: flex;
168 | align-items: center;
169 | }
170 |
171 | .shoeName div .big{
172 | margin-right: 10px;
173 | font-size: 2rem;
174 | color: #333;
175 | line-height: 1;
176 | }
177 |
178 | .shoeName div .new{
179 | background-color: var(--primary);
180 | text-transform: uppercase;
181 | color: #fff;
182 | padding: 3px 10px;
183 | border-radius: 5px;
184 | transition: .5s;
185 | }
186 |
187 | .shoeName .small{
188 | font-weight: 500;
189 | color: #444;
190 | margin-top: 3px;
191 | text-transform: capitalize;
192 | }
193 |
194 | .shoeName, .description, .color-container, .size-container{
195 | border-bottom: 1px solid #dadada;
196 | }
197 |
198 | .description{
199 | padding: 10px 0;
200 | }
201 |
202 | .title{
203 | color: #3a3a3a;
204 | font-weight: 600;
205 | font-size: 1.2rem;
206 | text-transform: uppercase;
207 | }
208 |
209 | .text{
210 | color: #555;
211 | font-size: 17px;
212 | }
213 |
214 | .color-container{
215 | padding: 10px 0;
216 | }
217 |
218 | .colors{
219 | padding: 8px 0;
220 | display: flex;
221 | align-items: center;
222 | }
223 |
224 | .color{
225 | width: 25px;
226 | height: 25px;
227 | border-radius: 50%;
228 | margin: 0 10px;
229 | border: 5px solid;
230 | cursor: pointer;
231 | transition: .5s;
232 | }
233 |
234 | .color[color="blue"]{
235 | background-color: #2175f5;
236 | border-color: #2175f5;
237 | }
238 |
239 | .color[color="red"]{
240 | background-color: #f84848;
241 | border-color: #f84848;
242 | }
243 |
244 | .color[color="green"]{
245 | background-color: #29b864;
246 | border-color: #29b864;
247 | }
248 |
249 | .color[color="orange"]{
250 | background-color: #ff5521;
251 | border-color: #ff5521;
252 | }
253 |
254 | .color[color="black"]{
255 | background-color: #444;
256 | border-color: #444;
257 | }
258 |
259 | .color.active{
260 | border-color: #fff;
261 | box-shadow: 0 0 10px .5px rgba(0, 0, 0, 0.2);
262 | transform: scale(1.1);
263 | }
264 |
265 | .size-container{
266 | padding: 10px 0;
267 | margin-bottom: 10px;
268 | }
269 |
270 | .sizes{
271 | padding: 8px 0;
272 | display: flex;
273 | align-items: center;
274 | }
275 |
276 | .size{
277 | width: 40px;
278 | height: 40px;
279 | border-radius: 6px;
280 | background-color: #eee;
281 | margin: 0 10px;
282 | text-align: center;
283 | line-height: 40px;
284 | font-size: 1.1rem;
285 | font-weight: 500;
286 | cursor: pointer;
287 | transition: .3s;
288 | }
289 |
290 | .size.active{
291 | background-color: var(--primary);
292 | color: #fff;
293 | transition: .5s;
294 | }
295 |
296 | .buy-price{
297 | padding-top: 15px;
298 | display: flex;
299 | justify-content: space-between;
300 | align-items: center;
301 | }
302 |
303 | .price{
304 | color: #333;
305 | display: flex;
306 | align-items: flex-start;
307 | }
308 |
309 | .price h1{
310 | font-size: 2.1rem;
311 | font-weight: 600;
312 | line-height: 1;
313 | }
314 |
315 | .price i{
316 | font-size: 1.4rem;
317 | margin-right: 1px;
318 | }
319 |
320 | .buy{
321 | padding: .7rem 1rem;
322 | background-color: var(--primary);
323 | text-decoration: none;
324 | color: #fff;
325 | text-transform: uppercase;
326 | letter-spacing: 1px;
327 | font-weight: 500;
328 | font-size: 1.1rem;
329 | transition: .5s;
330 | }
331 |
332 | .buy:hover{
333 | transform: scale(1.1);
334 | }
335 |
336 | .buy i{
337 | margin-right: 2px;
338 | }
339 |
340 | @media (max-width: 1070px){
341 | .shoe{
342 | width: 135%;
343 | }
344 | }
345 |
346 | @media (max-width: 1000px){
347 | .card{
348 | flex-direction: column;
349 | width: 100%;
350 | box-shadow: 0 0 35px 1px rgba(0, 0, 0, 0.2);
351 | }
352 |
353 | .card > div{
354 | width: 100%;
355 | box-shadow: none;
356 | }
357 |
358 | .shoe{
359 | width: 100%;
360 | transform: rotate(-5deg) translateY(-50%);
361 | top: 55%;
362 | right: 2%;
363 | }
364 |
365 | .nike{
366 | top: 20%;
367 | left: 5%;
368 | }
369 | }
370 |
371 | @media (max-width: 600px){
372 | .share{
373 | width: 40px;
374 | height: 40px;
375 | }
376 |
377 | .share i {
378 | font-size: 1rem;
379 | line-height: 40px;
380 | }
381 |
382 | .logo{
383 | width: 70px;
384 | }
385 | }
386 |
387 | @media (max-width: 490px){
388 | .nike{
389 | font-size: 7rem;
390 | }
391 |
392 | .shoeName div .big{
393 | font-size: 1.3rem;
394 | }
395 |
396 | .small{
397 | font-size: 1rem;
398 | }
399 |
400 | .new{
401 | padding: 2px 6px;
402 | font-size: .9rem;
403 | }
404 |
405 | .title{
406 | font-size: .9rem;
407 | }
408 |
409 | .text{
410 | font-size: .8rem;
411 | }
412 |
413 | .buy{
414 | padding: .5rem .8rem;
415 | font-size: .8rem;
416 | }
417 |
418 | .price h1{
419 | font-size: 1.5rem;
420 | }
421 |
422 | .price i{
423 | font-size: .9rem;
424 | }
425 |
426 | .size{
427 | width: 30px;
428 | height: 30px;
429 | margin: 0 8px;
430 | font-size: .9rem;
431 | line-height: 30px;
432 | }
433 |
434 | .color{
435 | margin: 0 6px;
436 | width: 0 20px;
437 | width: 20px;
438 | height: 20px;
439 | border-width: 4px;
440 | }
441 |
442 | .share{
443 | width: 35px;
444 | height: 35px;
445 | top: 10px;
446 | right: 10px;
447 | }
448 |
449 | .share i{
450 | font-size: .8rem;
451 | line-height: 35px;
452 | }
453 |
454 | .logo{
455 | width: 60px;
456 | top: 10px;
457 | left: 10px;
458 | }
459 |
460 | .info{
461 | padding: 20px;
462 | }
463 | }
464 |
465 | @media (max-width: 400px){
466 | .buy i{
467 | display: none;
468 | }
469 |
470 | .container{
471 | padding: 20px;
472 | }
473 | }
--------------------------------------------------------------------------------