Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 3 years ago

Using SASS as pre-processor

sass/scss
Obhasa Tanto Yangkasa Putra•200
@obhasa12
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Margin is difficult, but I try my best to learn it...

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Elaine•11,360
    @elaineleung
    Posted almost 3 years ago

    Hi Obhasa, great job at attempting this challenge! As mentioned by @PPechmann above, you can try centering the component with flexbox using his method, and if you do that, you can remove the margins you have for the container.

    Some other comments I have:

    1. Right now the layout changes to desktop view with a lot of space around the component; I'd try making the breakpoint smaller so that there won't be so much space.

    2. Your component isn't so responsive right now, unforunately! That means it doesn't really resize or "respond" when the browser width changes, and the width is fairly fixed. I usually would say, just change the width to max-width, which is a fairly easy solution. ln your case, because you have the images as background images, instead of using max-width, you can try width: min(100%, 37.6875rem) instead. The better solution, however, is just to change the background images to the picture element, since this is a product image and is central to the content, therefore you'd want the screen reader to pick up on the image (which it can't if you're using a background image). To do that, try this in your code:

      <picture>
         <source media="(min-width: 64em)" srcset="image-desktop.png" />
         <img src="image-mobile.png" alt="Glass perfume bottle placed against a leafy background" />   
      </picture>
      
    3. To make the image width more or less equal with the text, try adding flex: 1 0 50% to the item__image.

    Hope some of this can help you out!

    Marked as helpful
  • Patrick•800
    @PPechmann
    Posted almost 3 years ago

    Hi @obhasa12,

    congrats on the challenge!

    I really like your approach and the code looks pretty clean too, well done 💪

    As a small improvement, I suggest centering the card properly with flexbox. For it to work, you need to give the body a min-height: 100vh, to cover the full viewport, and then simply the following (also on the body):

    display: flex;
    align-items: center;
    justify-content: center;
    

    Hope this is helpful and I am looking forward to more completed challenges 😉

    Happy coding!

    Patrick

    Marked as helpful
  • Chris•1,030
    @BlackSun225
    Posted almost 3 years ago

    Good debut, with practice you will be better. Congratulations

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.

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

Oops! 😬

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

Log in with GitHub