Skip to content

Responsive product preview card with large image and sale pricing

Notifications You must be signed in to change notification settings

AlexKMarshall/product-preview-card

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Product preview card component solution

Live Preview

This is a solution to the Product preview card component challenge on Frontend Mentor.

Table of contents

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

Product preview card showing product image, name, price and ability to add to cart

Links

My process

Built with

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

What I learned

I used this as a simple project to explore CUBE CSS. Specifically in this project I've used fluid typography and space scales to keep a visual rhythm and have subtly bigger text on larger screens.

I had attempted to use the principles of intrinsic design, and avoid media queries. However, that conflicts with using the <picture> element for art direction. The picture element needs a media query to know when to serve which aspect ratio of image. To avoid this happening at a different point to the layout changing from vertical to horizontal, I had to use a media query with the same breakpoint for both. This makes the implementation less resiliant to how the component would be used within the page. However, I don't see any way around this. Even container queries wouldn't solve the <picture> issue.

I've used a lot of CSS custom properties here. One use I particularly like is for setting up default transition properties. This allowed me to override just the motion animation for users with prefers-reduced-motion. Many CSS resets switch off all animations in this case, but here this still allows opacity and color changes to have transitions, giving a more elegant result.

Useful resources

  • CUBE CSS - I followed the broad ideas of CUBE to keep the CSS organized.
  • Utopia - I used Utopia to generate the fluid size and spacing scales.

Author

About

Responsive product preview card with large image and sale pricing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published