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

Responsive Stats Page With CSS Flexbox

Jimmy•60
@MonetCode88
A solution to the Stats preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Edit: The screenshot on the solution tab looks different than my solution not sure what that's about but I would love feedback.

I found it challenging to align the bottom row of text properly and it took a lot of trial and error to get it to look proper. I would love to know some better techniques than the one I used to make this work properly as I am unsure if that was the proper way.

What is the best practice in regard to scaling text?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Aditya Yadav•710
    @mraditya1999
    Posted almost 2 years ago

    For enhanced responsiveness and simplified background image integration, consider removing the fixed width and height properties from the container. Instead, utilize a single div to enclose the image, and apply flex properties to the "card-info" and "card-img" elements with a value of "flex: 1". This approach allows the card to adapt fluidly to different screen sizes while maintaining its proportion and providing a more professional user experience.

    HTML:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Centered Card with Responsive Image</title>
      <link rel="stylesheet" href="styles.css">
    </head>
    <body>
      <main>
        <div class="card">
          <div class="card-img">
            <!-- Place your image here -->
            <img src="your-image.jpg" alt="Card Image">
          </div>
          <div class="card-info">
            <!-- Card content -->
          </div>
        </div>
      </main>
    </body>
    </html>
    

    CSS (styles.css):

    body {
      margin: 0;
      padding: 0;
    }
    
    main {
      min-height: 100vh;
      display: grid;
      place-items: center;
      /* Additional main container styles can be added if needed */
    }
    
    .card {
      display: flex;
      /* Add more card styles as per design requirements */
    }
    
    .card-img {
      flex: 1;
      /* Additional styles for the image container can be included here */
    }
    
    .card-info {
      flex: 1;
      /* Additional styles for the card information container can be added here */
    }
    

    With this implementation, the card will naturally adjust its size and proportion based on the content and the screen's dimensions, providing an improved user experience on various devices. The background image is replaced by a more structured approach using a separate div for the image and employing flex properties to make the card content more responsive and visually appealing.

    Marked as helpful

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