Skip to main content
  1. All Posts/

ecommerce-product-page-main

eCommerce CSS

Frontend Mentor – E-commerce product page solution

This is a solution to the E-commerce product page challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the site depending on their device’s screen size
  • See hover states for all interactive elements on the page
  • Open a lightbox gallery by clicking on the large product image
  • Switch the large product image by clicking on the small thumbnail images
  • Add items to the cart
  • View the cart and remove items from it

Screenshot

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • CSS Grid
  • Mobile-first workflow

What I learned

I used this function to control the display of image when the arrow button is clicked

function leftSlide(image) {
  reset(image);
  if (current === 0) {
    current = image.length;
  }
  image[current - 1].style.display = "block";
  current--;
}

and
to override the light box image

btnContainer.addEventListener("click", (e) => {
  let somw = e.target;
  console.log(somw);
  if (somw.classList.contains("thumbone")) {
    largeImg.innerHTML = `<img src="https://github.com/ibimina/images/image-product-1.jpg" alt="" />`;
  } else if (somw.classList.contains("thumbtwo")) {
    largeImg.innerHTML = `<img src="https://github.com/ibimina/images/image-product-2.jpg" alt="" />`;
  } else if (somw.classList.contains("thumbthree")) {
    largeImg.innerHTML = `<img src="https://github.com/ibimina/images/image-product-3.jpg" alt="" />`;
  } else if (somw.classList.contains("thumbfour")) {
    largeImg.innerHTML = `<img src="https://github.com/ibimina/images/image-product-4.jpg" alt="" />`;
  }
});

Continued development

Working on Mobile design web page and image slider

Author