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

Responsive Card using Flexbox

Lisa T•40
@lisacodesnow
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I found getting the height of the image in desktop view the most challenging.

I tried using '100vh', something I had never used before and couldn't figure out how other solutions used it correctly.

Everytime I set the height to the parent element instead of to the actual background element, it would enlongate the entire container and I would have a really long image and short text.

And when I tried to set min-height: 100vh I couldn't see the image at all.

So I just used image tags, gave each image its own seperate class, and set one to display: none and another to display: inline.

Even though it worked I still had to finesse the height and set it to 40% instead of 100% so the container wouldn't be too long.

The question is why can't the image be the same height as the text beside it, without adding a fixed height or guessing a percentage?

I used flex to center the container on the main and cross axis, but in desktop and other mobile screen sizes I have all of this extra space at the bottom.

Is there a way to get the card in the middle of the screen or will there always be extra space at the bottom?

Overall, this was a fun project and a great intro into coding. Can't wait to do more.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Plinsinga•310
    @codedforfree
    Posted almost 3 years ago

    Hey Lisa,

    Good try. Indeed you could set Html, body {height:100%} or body {height: 100vh:}. Furthermore, I would read a bit about the picture element. Here.

    Another thing I would do is make the 'perfume' text uppercase and add some letter spacing to it. Next to that, I would check my overall widths a bit better.

    But this is a good start to learning and working on your front-end skills, so keep it up.

    Marked as helpful
  • Nirajan Prasad•190
    @behubj
    Posted almost 3 years ago

    Hey Lisa, Well try you tried your best to complete your project, i appericiate that.

    If you want to center your "container_wrapper" you have to fix your code{ Do (html,body: height-100%;)} it will fix your code and your <div> comes in center horizontally and verically.

    Hope it will help you and if you want you can check my solution. Happy coding...

    Marked as helpful
  • Phúc (Scott) Nguyễn•430
    @NationsAnarchy
    Posted almost 3 years ago

    Hey Lisa! As I always tell myself, no matter what we code - we can always improve on it by learning and doing.

    Since there are two great comments above already, I can also suggest you to check the HTML Report option, as there are a couple of things you can do to make your HTML file more structruely correct and usable.

    Keep it going! I believe that you're in the right track, and I hope you have fun doing this as much as I do.

    Phúc (Scott).

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