How we can create a product card for an eCommerce site? Solution: See this CSS Product Card Design With jQuery, Ecommerce Product’s Card UI with advanced features.
Previously I have shared many types of Card Design, but this is a complete e-commerce card. Basically card is a group of multiple contents which is composed in a single element and creates valuable info to users. When you open an eCommerce site then there you can see products list with their image and info text, every single item is called card.
Today you will learn to create Ecommerce Product’s Card UI design. Basically in this design, you can see an image, title, and price first. When you will hover on that, then you can see sizes and available colors. Also, an overlay button will appear on the image for seeing details after clicking that button you can see all image of that product.
So, Today I am sharing CSS Product Card Design With jQuery. The design is created using CSS and functions are created using jQuery. As you know jQuery is JS library that’s why I am putting this in JavaScript category. This program has a flip, toggle, and carousel feature which is powered by JS. I am sure that you will like this program, and you can use this on your website.
If you are thinking now how this card design actually is, then see the preview given below.
Preview of Ecommerce Product’s Card With Flip, Carousel Features
See this video preview to getting an idea of how this UI design and effect looks like.
Now you can see this visually, you also can see it live by pressing the button given above. If you like this, then get the source code of its.
You May Also Like:
- SVG Search Input Animation
- JavaScript Slideshow With Controls
- Responsive Infographic Cards
- CSS Image Gallery With 3D Effect
CSS Product Card Design With jQuery Source Code
Before sharing source code, let’s talk about it. First I have created the main div named container and placed all the divs and section inside it. There is lots of divs for main and small things like for image, title, overview tab, colors, etc. I have placed four images inside that design one is small which is placed on the card and the other three are little large which you can see after opening the carousel.
Now using CSS, I have placed all the elements on the right place and gave color, position, margin, padding, etc values. Here I have used a google font, and linked in the HTML file. As you can see in the preview there is a flip effect, which is created using lots of CSS transform commands (info). And many more basic CSS stuffs are placed inside the file.
Here jQuery handling most of the main features, like flip effect, close button action, carousel next and previous, etc. Basically, JS adds and removes the CSS values according to action. I have left comments in the JS file, with the help of that you can understand the coding part of each feature. As you can understand there are lots of codes I can’t explain in writing, You will understand after getting the codes.
For creating this program you have to create 3 files for that. First for HTML, second for CSS, and the third for JavaScript. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
<!DOCTYPE html> <!--Code By Webdevtrick ( https://webdevtrick.com )--> <html lang="en" > <head> <meta charset="UTF-8"> <title>Ecommerce Product Card | Webdevtrick.com</title> <link rel="stylesheet" href="style.css"> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'> </head> <body> <div id="container"> <div id="product-card"> <div id="front-side"> <div class="shadow"></div> <img src="https://webdevtrick.com/wp-content/uploads/jordan.jpg" alt="" /> <div class="image_overlay"></div> <div id="detailsV">View details</div> <div class="details"> <div class="details-container"> <span class="price">$249</span> <span class="title">Nike Air Jordan</span> <p>Basketball Shoes & Sneakers</p> <div class="select-option"> <strong>SIZES</strong> <span>US8, US8.5, US9, US9.5</span> <strong>COLORS</strong> <div class="colors"> <div class="whiteC"><span></span></div> <div class="blueC"><span></span></div> <div class="yellowC"><span></span></div> <div class="redC"><span></span></div> </div> </div> </div> </div> </div> <div id="back-side"> <div class="shadow"></div> <div id="carousel"> <ul> <li><img src="https://webdevtrick.com/wp-content/uploads/jordan-large.jpg" alt="" /></li> <li><img src="https://webdevtrick.com/wp-content/uploads/side-view.jpg" alt="" /></li> <li><img src="https://webdevtrick.com/wp-content/uploads/back-side.jpg" alt="" /></li> </ul> <div class="arrow-buttons"> <div class="PreIMG"> <div class="y"></div> <div class="x"></div> </div> <div class="NextIMG"> <div class="y"></div> <div class="x"></div> </div> </div> </div> <div id="back-flip"> <div id="cy"></div> <div id="cx"></div> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <script src="function.js"></script> </body> </html> |
style.css
Now create a CSS file named ‘style.css‘ and put these codes given here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
/* Code By Webdevtrick ( https://webdevtrick.com ) */ * { margin: 0px; padding: 0px; } body { background: #eaebec; font-family: "Open Sans", sans-serif; } #view-code{ color:#ff5757; font-size:14px; text-transform:uppercase; font-weight:700; text-decoration:none; position:absolute; top:640px; left:50%; margin-left:-35px; } #view-code:hover{color:#34c29e;} #container{ position: relative; perspective: 800px; width:340px; height:500px; transform-style: preserve-3d; transition: transform 5s; position:absolute; top:80px; left:50%; margin-left:-167px; } #front-side, #back-side{ width:335px; height:500px; background:#fff; position:absolute; left:-5px; top:-5px; -webkit-transition: all 100ms ease-out; -moz-transition: all 100ms ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #back-side{ display:none; transform: rotateY( 180deg ); } #product-card.animate #back-side, #product-card.animate #front-side{ top:0px; left:0px; -webkit-transition: all 100ms ease-out; -moz-transition: all 100ms ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #product-card{ width:325px; height:490px; position:absolute; top:10px; left:10px; overflow:hidden; transform-style: preserve-3d; -webkit-transition: 100ms ease-out; -moz-transition: 100ms ease-out; -o-transition: 100ms ease-out; transition: 100ms ease-out; } div#product-card.flip-10{ -webkit-transform: rotateY( -10deg ); -moz-transform: rotateY( -10deg ); -o-transform: rotateY( -10deg ); transform: rotateY( -10deg ); transition: 50ms ease-out; } div#product-card.flip90{ -webkit-transform: rotateY( 90deg ); -moz-transform: rotateY( 90deg ); -o-transform: rotateY( 90deg ); transform: rotateY( 90deg ); transition: 100ms ease-in; } div#product-card.flip190{ -webkit-transform: rotateY( 190deg ); -moz-transform: rotateY( 190deg ); -o-transform: rotateY( 190deg ); transform: rotateY( 190deg ); transition: 100ms ease-out; } div#product-card.flip180{ -webkit-transform: rotateY( 180deg ); -moz-transform: rotateY( 180deg ); -o-transform: rotateY( 180deg ); transform: rotateY( 180deg ); transition: 150ms ease-out; } #product-card.animate{ top:5px; left:5px; width:335px; height:500px; box-shadow:0px 13px 21px -5px rgba(0, 0, 0, 0.3); -webkit-transition: 100ms ease-out; -moz-transition: 100ms ease-out; -o-transition: 100ms ease-out; transition: 100ms ease-out; } .details-container{ background:#fff; position:absolute; top:386px; left:0; width:265px; height:300px; padding:27px 35px 35px; -webkit-transition: all 200ms ease-out; -moz-transition: all 200ms ease-out; -o-transition: all 200ms ease-out; transition: all 200ms ease-out; } #product-card.animate .details-container{ top:272px; -webkit-transition: all 200ms ease-out; -moz-transition: all 200ms ease-out; -o-transition: all 200ms ease-out; transition: all 200ms ease-out; } .details-container .title{ font-size:22px; color:#393c45; } .details-container p{ font-size:16px; color:#b1b1b3; padding:2px 0 20px 0; } .details-container .price{ float:right; color:#ff5757; font-size:22px; font-weight:600; } .image_overlay{ position:absolute; top:0; left:0; width:100%; height:100%; background:#ff5757; opacity:0; } #product-card.animate .image_overlay{ opacity:0.7; -webkit-transition: all 200ms ease-out; -moz-transition: all 200ms ease-out; -o-transition: all 200ms ease-out; transition: all 200ms ease-out; } .select-option{ padding:2px 0 0; } .select-option strong{ font-weight:700; color:#393c45; font-size:14px; } .select-option span{ color:#969699; font-size:14px; display:block; margin-bottom:8px; } #detailsV{ position:absolute; top:112px; left:50%; margin-left:-85px; border:2px solid #fff; color:#fff; font-size:19px; text-align:center; text-transform:uppercase; font-weight:700; padding:10px 0; width:172px; opacity:0; -webkit-transition: all 200ms ease-out; -moz-transition: all 200ms ease-out; -o-transition: all 200ms ease-out; transition: all 200ms ease-out; } #detailsV:hover{ background:#fff; color:#ff5757; cursor:pointer; } #product-card.animate #detailsV{ opacity:1; width:152px; font-size:15px; margin-left:-75px; top:115px; -webkit-transition: all 200ms ease-out; -moz-transition: all 200ms ease-out; -o-transition: all 200ms ease-out; transition: all 200ms ease-out; } div.colors div{ margin-top:3px; width:15px; height:15px; margin-right:5px; float:left; } div.colors div span{ width:15px; height:15px; display:block; border-radius:50%; } div.colors div span:hover{ width:17px; height:17px; margin:-1px 0 0 -1px; } div.blueC span{background:#2ab1ce;} div.yellowC span{background:#fd9d08;} div.redC span{background:#ff3838;} div.whiteC span{ background:#fff; width:14px; height:14px; border:1px solid #e8e9eb; } div.shadow{ width:335px;height:520px; opacity:0; position:absolute; top:0; left:0; z-index:3; display:none; background: -webkit-linear-gradient(left,rgba(0,0,0,0.1),rgba(0,0,0,0.2)); background: -o-linear-gradient(right,rgba(0,0,0,0.1),rgba(0,0,0,0.2)); background: -moz-linear-gradient(right,rgba(0,0,0,0.1),rgba(0,0,0,0.2)); background: linear-gradient(to right, rgba(0,0,0,0.1), rgba(0,0,0,0.2)); } #back-side div.shadow{ z-index:10; opacity:1; background: -webkit-linear-gradient(left,rgba(0,0,0,0.2),rgba(0,0,0,0.1)); background: -o-linear-gradient(right,rgba(0,0,0,0.2),rgba(0,0,0,0.1)); background: -moz-linear-gradient(right,rgba(0,0,0,0.2),rgba(0,0,0,0.1)); background: linear-gradient(to right, rgba(0,0,0,0.2), rgba(0,0,0,0.1)); } #back-flip{ position:absolute; top:20px; right:20px; width:30px; height:30px; cursor:pointer; } #cx, #cy{ background:#d2d5dc; position:absolute; width:0px; top:15px; right:15px; height:3px; -webkit-transition: all 250ms ease-in-out; -moz-transition: all 250ms ease-in-out; -ms-transition: all 250ms ease-in-out; -o-transition: all 250ms ease-in-out; transition: all 250ms ease-in-out; } #back-flip:hover #cx, #back-flip:hover #cy{ background:#979ca7; -webkit-transition: all 250ms ease-in-out; -moz-transition: all 250ms ease-in-out; -ms-transition: all 250ms ease-in-out; -o-transition: all 250ms ease-in-out; transition: all 250ms ease-in-out; } #cx.s1, #cy.s1{ right:0; width:30px; -webkit-transition: all 100ms ease-out; -moz-transition: all 100ms ease-out; -ms-transition: all 100ms ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #cy.s2{ -ms-transform: rotate(50deg); -webkit-transform: rotate(50deg); transform: rotate(50deg); -webkit-transition: all 100ms ease-out; -moz-transition: all 100ms ease-out; -ms-transition: all 100ms ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #cy.s3{ -ms-transform: rotate(45deg); -webkit-transform: rotate(45deg); transform: rotate(45deg); -webkit-transition: all 100ms ease-out; -moz-transition: all 100ms ease-out; -ms-transition: all 100ms ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #cx.s1{ right:0; width:30px; -webkit-transition: all 100ms ease-out; -moz-transition: all 100ms ease-out; -ms-transition: all 100ms ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #cx.s2{ -ms-transform: rotate(140deg); -webkit-transform: rotate(140deg); transform: rotate(140deg); -webkit-transition: all 100ms ease-out; -moz-transition: all 100ms ease-out; -ms-transition: all 100ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #cx.s3{ -ms-transform: rotate(135deg); -webkit-transform: rotate(135deg); transform: rotate(135deg); -webkit-transition: all 100ease-out; -moz-transition: all 100ms ease-out; -ms-transition: all 100ms ease-out; -o-transition: all 100ms ease-out; transition: all 100ms ease-out; } #carousel{ width:335px; height:500px; overflow:hidden; position:relative; } #carousel ul{ position:absolute; top:0; left:0; } #carousel li{ width:335px; height:500px; float:left; overflow:hidden; } .arrow-buttons{ width:335px; height:55px; position: absolute; top: 218px; transform-style: preserve-3d; transition: transform 5s; perspective: 335px; } .PreIMG, .NextIMG{ width: 50px; height: 55px; background: #ccc; position: absolute; top:0; transition: all 200ms ease-out; opacity:0.9; cursor:pointer; } .NextIMG{ top:0; right: -26px; -webkit-transform: rotateY( -117deg ); -moz-transform: rotateY( -117deg ); -o-transform: rotateY( -117deg ); transform: rotateY( -117deg ); transition: all 200ms ease-out; } .NextIMG.visible{ right:0; opacity:0.8; background: #efefef; -webkit-transform: rotateY( 0deg ); -moz-transform: rotateY( 0deg ); -o-transform: rotateY( 0deg ); transform: rotateY( 0deg ); transition: all 200ms ease-out; } .PreIMG{ left:-26px; top:0; -webkit-transform: rotateY( 117deg ); -moz-transform: rotateY( 117deg ); -o-transform: rotateY( 117deg ); transform: rotateY( 117deg ); transition: all 200ms ease-out; } .PreIMG.visible{ left:0; opacity:0.8; background: #eee; -webkit-transform: rotateY( 0deg ); -moz-transform: rotateY( 0deg ); -o-transform: rotateY( 0deg ); transform: rotateY( 0deg ); transition: all 200ms ease-out; } #carousel .x, #carousel .y{ height:2px; width:15px; background:#ff5757; position:absolute; top:31px; left:17px; -ms-transform: rotate(45deg); -webkit-transform: rotate(45deg); transform: rotate(45deg); } #carousel .x{ -ms-transform: rotate(135deg); -webkit-transform: rotate(135deg); transform: rotate(135deg); top:21px; } #carousel .NextIMG .x{ -ms-transform: rotate(45deg); -webkit-transform: rotate(45deg); transform: rotate(45deg); } #carousel .NextIMG .y{ -ms-transform: rotate(135deg); -webkit-transform: rotate(135deg); transform: rotate(135deg); } |
function.js
The final step, create a JavaScript file named ‘funciton.js‘ and put the codes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
// Code By Webdevtrick ( https://webdevtrick.com ) $(document).ready(function(){ // show details $('#product-card').hover(function(){ $(this).addClass('animate'); $('div.NextIMG, div.PreIMG').addClass('visible'); }, function(){ $(this).removeClass('animate'); $('div.NextIMG, div.PreIMG').removeClass('visible'); }); // back flip $('#detailsV').click(function(){ $('div.NextIMG, div.PreIMG').removeClass('visible'); $('#product-card').addClass('flip-10'); setTimeout(function(){ $('#product-card').removeClass('flip-10').addClass('flip90').find('div.shadow').show().fadeTo( 80 , 1, function(){ $('#front-side, #front-side div.shadow').hide(); }); }, 50); setTimeout(function(){ $('#product-card').removeClass('flip90').addClass('flip190'); $('#back-side').show().find('div.shadow').show().fadeTo( 90 , 0); setTimeout(function(){ $('#product-card').removeClass('flip190').addClass('flip180').find('div.shadow').hide(); setTimeout(function(){ $('#product-card').css('transition', '100ms ease-out'); $('#cx, #cy').addClass('s1'); setTimeout(function(){$('#cx, #cy').addClass('s2');}, 100); setTimeout(function(){$('#cx, #cy').addClass('s3');}, 200); $('div.NextIMG, div.PreIMG').addClass('visible'); }, 100); }, 100); }, 150); }); // front flip $('#back-flip').click(function(){ $('#product-card').removeClass('flip180').addClass('flip190'); setTimeout(function(){ $('#product-card').removeClass('flip190').addClass('flip90'); $('#back-side div.shadow').css('opacity', 0).fadeTo( 100 , 1, function(){ $('#back-side, #back-side div.shadow').hide(); $('#front-side, #front-side div.shadow').show(); }); }, 50); setTimeout(function(){ $('#product-card').removeClass('flip90').addClass('flip-10'); $('#front-side div.shadow').show().fadeTo( 100 , 0); setTimeout(function(){ $('#front-side div.shadow').hide(); $('#product-card').removeClass('flip-10').css('transition', '100ms ease-out'); $('#cx, #cy').removeClass('s1 s2 s3'); }, 100); }, 150); }); // Carousel var carousel = $('#carousel ul'); var carouselSlideWidth = 335; var carouselWidth = 0; var isAnimating = false; // building width of casousel $('#carousel li').each(function(){ carouselWidth += carouselSlideWidth; }); $(carousel).css('width', carouselWidth); // Next Image $('div.NextIMG').on('click', function(){ var currentLeft = Math.abs(parseInt($(carousel).css("left"))); var newLeft = currentLeft + carouselSlideWidth; if(newLeft == carouselWidth || isAnimating === true){return;} $('#carousel ul').css({'left': "-" + newLeft + "px", "transition": "300ms ease-out" }); isAnimating = true; setTimeout(function(){isAnimating = false;}, 300); }); // Previous Image $('div.PreIMG').on('click', function(){ var currentLeft = Math.abs(parseInt($(carousel).css("left"))); var newLeft = currentLeft - carouselSlideWidth; if(newLeft < 0 || isAnimating === true){return;} $('#carousel ul').css({'left': "-" + newLeft + "px", "transition": "300ms ease-out" }); isAnimating = true; setTimeout(function(){isAnimating = false;}, 300); }); }); |
That’s It. Now you have successfully created CSS Product Card Design With jQuery, Ecommerce Product’s Card UI. If you have any doubt or question comment down below.
Thanks For Visiting, Keep Visiting.
Excellent post. I was looking for something very different,
but stumbled on your site. I am happy I did. Thank
you for sharing
useful information. Thank you and best of luck.