Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 8 months ago

Responsive product card using Flexbox and CSS Grid

Sudharshan Murugan•50
@SudharMurugan
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

What I'm most proud of:

Responsive Design: I take particular pride in the layout's responsiveness. It effectively adjusts to various screen dimensions, particularly transitioning from mobile to desktop displays, utilizing CSS Grid and Flexbox. Streamlined and Aesthetic Design: I have successfully developed a straightforward yet visually engaging design that accentuates the product while preserving clarity in textual hierarchy and spacing. Interactivity: The "Add to Cart" button features a seamless hover effect that improves user experience without using JavaScript. This exemplifies the efficacy of CSS in managing interactive elements.

What I would do differently next time:

Enhancements in Accessibility: I would prioritize accessibility improvements. Incorporating aria labels and enhancing button accessibility for screen readers could enhance the user experience for individuals with disabilities. Image Optimization: The product image could be further optimized for expedited loading times, particularly for mobile users, by employing responsive image sizes (srcset). Utilization of CSS Variables: I could employ CSS variables to retain colors and font sizes, so enhancing code maintainability and facilitating future customization. Font Consistency: Although the Montserrat and Fraunces typefaces complement each other, I may explore alternative font combinations to enhance readability or achieve a more distinctive look.

What challenges did you encounter, and how did you overcome them?
  1. Attaining a Responsive Layout:

Challenge: Ensuring the design is responsive across various devices (mobile, tablet, and desktop) while maintaining a consistent and user-friendly interface. Solution: I employed CSS Grid and Flexbox to develop a versatile layout. CSS Grid was very effective for structuring material systematically, but Flexbox facilitated the alignment and centering of items. I established breakpoints for smaller displays to dynamically modify the layout, providing optimal appearance across all devices.

  1. Image Management and Responsiveness:

Challenge: Ensuring the product image is appropriately contained and responsive to varying screen sizes without distortion. Solution: I employed max-width: 100% and height: auto for the image to ensure responsiveness. This guaranteed that the image preserves its aspect ratio and adjusts appropriately according to the screen width.

  1. Typography Hierarchy & Spacing:

Challenge: Maintaining clarity and visual attractiveness of the text hierarchy (product name, description, price), particularly during the transition from desktop to mobile viewing. Solution: I meticulously utilized varying font sizes, weights, and spacing for each text piece. I employed larger fonts for the product name and price to enhance their visibility. I decreased the font size of the product description on mobile and implemented line breaks to maintain readability without encroaching on screen space.

  1. Button Aesthetics and Hover Interaction:

Task: Create a visually distinctive button that integrates seamlessly with the overall design, using hover effects for interactivity. Solution: I created a button including a minimalist background color and a delicate border-radius. I incorporated a hover effect that alters the backdrop color for interactivity. This was accomplished utilizing solely CSS, without the involvement of JavaScript, which functioned effectively and maintained a pristine design.

  1. Refining CSS:

Challenge: Maintaining uniform spacing and padding between items while ensuring precise alignment across diverse screen sizes. Resolution: I dedicated time on modifying the padding and margin values for various items through the utilization of media queries. I ensured to test the layout on several devices to verify that all elements were properly aligned and visually harmonious. Through the application of various CSS methodologies (Grid, Flexbox, media queries) and comprehensive testing, I successfully addressed these problems and produced a responsive, aesthetically pleasing product card.

What specific areas of your project would you like help with?
  1. Sophisticated CSS Strategies for Responsiveness:

Inquiry: Although I have utilized CSS Grid and Flexbox for responsive design, I seek opinion on further strategies or best practices for further optimizing layouts across a broader spectrum of screen sizes, particularly for bigger desktop displays (1440px+). What CSS techniques or tools can improve responsiveness and layout behavior?

  1. Performance Enhancement:

Inquiry: Are there recommendations for enhancing the efficacy of this project? I want to decrease load times while maintaining visual quality (e.g., picture optimization, lazy loading). What strategies can I employ to enhance performance, particularly for mobile users with limited connectivity?

  1. Accessibility of Buttons:

Inquiry: Although the buttons are crafted for visual attractiveness, I need input regarding their accessibility. What enhancements can I do to guarantee that the buttons are entirely accessible to all users, including those utilizing screen readers or keyboard navigation? Would the incorporation of ARIA labels or roles enhance the button's accessibility?

  1. Design Uniformity:

Request: I seek opinions on the overall design coherence. Do you believe the visual hierarchy (font sizes, button designs, spacing) is uniform throughout the project, particularly during transitions between mobile and desktop views? Are there specific locations where I can enhance visual balance or alignment to improve user experience?

  1. CSS File Dimensions:

Inquiry: Given the project's modest scale, my existing CSS file is not extensive; yet, I seek advice on maintaining modularity and ease of maintenance in the CSS as the project expands. What strategies can I employ to enhance my CSS management for scalability? By concentrating on these particular areas, I aim to obtain constructive comments that will enhance the overall quality and performance of the project.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Sudharshan Murugan's solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.