Code Monkey home page Code Monkey logo

product-preview-card's Introduction

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.

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 variables
  • Flex and Grid
  • CUBE CSS

I used a grid layout to place the photo and the product description side by side on the desktop version, changing the flow to column in the mobile version.

Flex was used to center elements and set gaps, which was really helpful.

Using CUBE flow component class was really helpful, clear way to set a margin top for all but the first child:

.flow > * + * {
  margin-top: 21px;
}

In this challenge, I didn't override the margin-top for the child elements, so I didn't had to set a variable with defaults.

I took me around 3 hours to finish it.

What I learned

Took a while to wrap my head around CUBE methodology, which I'm sure I did not follow 100%. I did enjoy using utility classes, which is similar to who tailwind works, but for this simple challenge it was hard to decide what would be a utility class and what I should style as a block.

I also noticed you have to place your media-query AFTER the values you are trying to override.

Placing the same prices on the same vertical level was annoying, but I think using flex was a good solution in the end.

Continued development

The CSS is far from perfect, and while I was not following CUBE 100%, I think it helped me create cleaner CSS.

The result is not pixel perfect, but I'm happy with it.

In real production code, I would use more variables and utility classes, since they are really helpful for changing code later and re-using classes.

Author

product-preview-card's People

Contributors

ralacerda avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.