Skip to content

sharonlhs/product-preview-card-component-main

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Product preview card component solution

This is a solution to the Product preview card component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Note: Delete this note and update the table of contents based on what sections you keep.

Overview

The challenge

Users should be able to:

  • View the optimal layout depending on their device's screen size
  • See hover and focus states for interactive elements

Screenshot

Links

Built with

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

What I learned

Learned how to set different images for different screen type with HTML and manipulate how the card looks like differently on desktop and mobile with CSS

srcset defines the set of images we will allow the browser to choose between, and what size each image is. Each set of image information is separated from the previous one by a comma.

HTML

<img
  srcset="images/image-product-desktop.jpg 600w,
  images/image-product-mobile.jpg  686w"
  sizes="(max-width: 600px) 686px, 300px"
  src="images/image-product-desktop.jpg"
  alt="A bottle of perfume surrounded by foliage"
/> 

CSS

@media only screen and (max-width: 600px) {}

Continued development

To enhance more on using flexbox and learn other different ways to showcase product details in desktop/mobile view

Useful resources

Author