Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

Display Flex centering Perfume challenge

Christopher Portorreal•90
@crixfer
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Centering and putting the image aside of the white box, then centering the text in the right-sided white box.

I tried adding Bootstrap coding, but it broke my codes every time. I need more practice.

What do you recommend to do these kinds of positioning and sizing without using so many codes? I really appreciate any help you can provide.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Harshit Joshi•120
    @TheFoxian
    Posted over 2 years ago

    Hey Christopher, congratulations on completing the challenge.

    Here are my few findings, you have used two images and displaying one image with hiding another at media breakpoint makes sense but it is not a good practice, instead use HTML source tag. Read more about HTML Source tag.

    Other than this you have used display flex directly to the main tag. This is not a good practice, instead use a div inside of main and wrap all the content inside it and apply the respective css to that wrapper. Read more about centring any element using flex

    Although you have used max width 600px but there are few standard for media breakpoints. Please refer this for better understanding -

    1. 320px — 480px: Mobile devices
    2. 481px — 768px: iPads, Tablets
    3. 769px — 1024px: Small screens, laptops
    4. 1025px — 1200px: Desktops, large screens
    5. 1201px and more —  Extra large screens, TV

    Keep up the good work! Enjoy coding :)

    Marked as helpful
  • generieyyc•160
    @generieyyc
    Posted over 2 years ago

    Hello! I'm sharing the feedback i got before.

    For proper centering the container (whole card) vertically and horizontally, you can use code as:

    body { min-height: 100vh; display: grid; place-content: center; }

    Hope that helps!

    Marked as helpful
  • Tamana•210
    @Tamana123-2
    Posted over 2 years ago

    Hello Mr. Christopher Portorreal! Great job for completing the challenge. In your mobile design you could use grid, for being more flexible with desktop version instead of flex. You can add the image of desktop design in HTML file with a media of (min-width: 600px) and in you CSS file you could go with (grid-template-columns: 1fr 1fr) for making the perfume image and content side by side. Go ahead even if it is hard to get. Nothing is easy to achieve. Nice time.

    Marked as helpful
  • Luca Liebenberg•180
    @lucaliebenberg
    Posted over 2 years ago

    hello, just for some extra feedback:

    If you want to centre the card - for desktop and mobile - you can use /* display: flex; height: 100vh; justify-content: center; align-items: center; */

    This for the body element, you can target directly in css:

    body {

    }

    I hope this has helped!

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
Frontend Mentor logo

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

Oops! 😬

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

Log in with GitHub