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

Responsive Stats Preview Card Component

Guilherme Moraes•30
@guilherme-dm
A solution to the Stats preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I'm curious about how you guys have handled responsivity on this one. I feel like i had to trigger a breaking point quite soon because text were starting to get very messy. If you have any suggestions, let me know 🤙

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Yazdun•1,310
    @Yazdun
    Posted over 3 years ago

    Hello Guilherme ! Well done on this challenge. I studied your approach a little bit and here are issues I found :

    GIT ISSUE

    • Before we get to the solution itself, There is a issue with your repo. I suggest you to create a main branch and put each solution on separate branch, so it will be easier to maintain the repo and also other people can contribute to your code more easily !

    SOLUTION ISSUE

    • You don't need two media queries, first write your style for mobile and only then, write a media query for desktop.
    • Instead of span, You must use div for block level elements, for example .text-content is a block level element so you must use div instead of span.
    • for stats, You'll be better off with something like
    <ul>
          <li>10k+<span>companies</span></li>
          <li>314 <span>templates</span></li>
          <li>12m+ <span>queries</span></li>
    </ul>
    

    instead of using div and span and heading. using ul is more efficient in this case IMO.

    • html elements are block level by default ( also this is one of the reason for why approaching mobile first is better ), so you won't need display:flex and flex-direction:column for initial style, you get the column by default.
    • Specify two font families in your styles, so if one of them is not supported by user's browser, the other one will be loaded and your design won't break.
    • Instead of .page-container, Use
    display:flex;
    justify-content:center;
    align-items:center;
    min-height:100vh;
    

    on body to centralize your element.

    • Instead of giving h1 and p text-align:center;, give their parent text-align:center and all children will inherit it.
    • You have access to the initial style you write for a element in media queries, so you only need to change parts that need to be changed, for example you don't need to specify font-family in media queries, it will remain the same anyway unless you want to change it.
    • Use prettier extension on your IDE to format your code.

    ✅ Also I opened a pull request to your repo which will fix some of these issues

    I hope this was helpful

    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 1st-party linked stylesheets, and styles within <style> tags.

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.

Oops! 😬

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

Log in with GitHub