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

Stats Preview Card with HTML and CSS

Myro Joy Lee•120
@myrojoylee
A solution to the Stats preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Almost done my first ever week of coding!

Here was my main issue in this one: How do I specify a width and height for both mobile and desktop version? Or is this not possible? I ended up getting mine sort of close to the desktop version upon stretching of the browser window but it is not really close to the mobile height dimension at all once you narrow it. Or will I learn to be better at this once I go along?

I am consistently struggling with margins, padding, and borders. I feel like if I change one it moves everything in the wrong direction so I will definitely need more practice with other challenges to get those fully understood.

Thanks to all those following me along :).

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Ambe Mbong-Nwi Nchang•550
    @Ambe-Mbong-Nwi
    Posted over 2 years ago

    Hello, I love your work. To specify the width using the desktop-first approach, in the body include the max width given in the style sheet

    body{
        max-width: 1440px;
        margin: 0 auto;
    }
    

    Later on, when modifying the styles for the mobile display, use the media query and specify the width of the mobile device there

    /*mobile design styles*/
    @media (max-width: 375px){
        body{
            max-width: 375px;
            margin: 0 auto;
        }
    

    Note: The "margin: 0 auto" is used to centralize your page on every screen both vertically and horizontally so it's necessary you include it in your work

    -Margins are used to create space around elements, outside of any defined borders.

    -Padding is used to create space around an element's content, inside of any defined borders.

    -The CSS border properties allow you to specify the style, width, and color of an element's border.

    Please check out the link CSS Margin - W3 Schools for more information about how they are used.

    Marked as helpful
  • Precious•490
    @2peagles
    Posted over 2 years ago

    Looks perfect, the code is very easy to read the only thing I noticed was the h1 you can put a spam inside of that and change the color like that instead of doing h1 h1 h1 just to save a few lines of coding. I swear for a week of coding this is really good, I was all over the place 😂 I think I probably still am I started using grid and took Kevin Powell's responsive course. I feel like maybe if you try the calc property for paddings that might work. Hope that 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 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