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

Stats preview challenge

Kariman Medhat•170
@KarimanMedhat
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 did a lot of research while working on this project and this is my first time enjoying that =D so I'm happy with it and used every piece of advice I took in the last projects.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Acme Gamers•295
    @AcmeGamers
    Posted about 3 years ago

    Hey there 👋,

    Congratulations 🥳! To be honest, you really did superbly 😃! I liked the way how you used the ::before pseudo-element to give the image a purple overlay, which itself was a great idea, hats off on that 👏. I'm glad you enjoyed doing the project the most as enjoying while making your own portfolio/design as it also matters 😊.

    Here are small recommendations which can further improve your code and make it easier for you to work with the code.

    Centering Elements

    Since your container class is a flexbox (that is using display:flex), you can use it to center your elements

    .container {
        /*   Your Code   */
        display: flex;
    		
        /*   New Addition   */
        align-items: center;      // Centers horizontally
        justify-content: center;  // Centers Vertically
        min-height: 100vh;        // Captures full-screen height
    
        // Note: it is recommended to use min-height since it is a good practice
    }
    

    Now you can remove the below code from your CSS file without any worries and it will show the same result!

    body {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50% , -50%);
    }
    

    Check this video out on how to use Flexbox Editor on chrome directly: https://github.com/AcmeGamers/stats-view-Kariman/blob/main/Flexbox.mkv

    Media Queries CSS Duplicity

    I noticed that you are using the same properties in media queries. Although you really don't need to specify the properties again, you can just define them once and it will show the result you want 🙂. Let me explain you this through an example:

    /*  This is a normal H1 heading with a color and a background   */
    h1 {
        color: red;
        background: blue;
        font-size: 40px;
    }
    
    /*  Now if you do this  */
    @media screen and (max-width: 425px) {
    
        h1 {
            font-size: 26px;
            // This way, only font-size will change.
            // And the color and background will remain the same.
            // Also works with ::before and ::after pseudo elements 😀
        }
    		
    }
    

    Commenting

    In addition, I would recommend making comments in your code, it will help you recognize the part of your code faster when you are working with larger projects. Here's an example:

    HTML

    https://github.com/AcmeGamers/sunnyside-shihab/blob/main/Screenshot_2778.png

    CSS

    https://github.com/AcmeGamers/sunnyside-shihab/blob/main/Screenshot_3560.png

    I hope these few tips help you to make your code better and make you more productive. Hoping to see your future success and amazing work as always, best of luck 😃!

    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