Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Stats Preview Card - Responsive HTML/CSS

P
Julieโ€ข 130

@jclegg31

Desktop design screenshot for the Stats preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


It actually went pretty well.

I think the media query could be more clear. Felt like I was going around adding px here and there. Probably a better way?

Open to hearing how to improve this code.

Thanks!

Community feedback

@MelvinAguilar

Posted

Hello there ๐Ÿ‘‹. Good job on completing the challenge !

I have some suggestions about your code that might interest you.

  • Instead of using separate properties for top, right, bottom, and left with position: absolute;, you can use the inset shorthand. For example, in your .main-image::before selector:
    .main-image::before {
        . . .
        /* top: 0; */
        /* right: 0; */
        /* bottom: 0; */
        /* left: 0; */
        inset: 0;
    }
    
  • Instead of having fixed values for properties like font-size, consider using the clamp() function. It allows for a scalable design by defining a minimum, preferred, and maximum value.
  • Instead of defining individual paddings and margins, consider using the shorthand. For example, the margin property in CSS has several shorthand properties that allow you to set the padding of multiple sides simultaneously:

    • margin: [top/bottom] [left/right];
    • margin: [top] [right/left] [bottom];
    • margin: [top] [right] [bottom] [left];
    .main-content p {
        /* margin-left: 0; */
        /* margin-right: 35px; */
        /* margin-bottom: 60px; */
        margin: 0 35px 60px 0;
        . . .
    }
    

    The same concepts of the margin shorthand can also apply to border-radius and padding:

    • border-radius: [top-left] [top-right] [bottom-right] [bottom-left];

  • Instead of setting borders directly on the image, you can apply the border to the container element. Additionally, to crop any overflow of the image, you can use the overflow: hidden property on the container.

    .main-container {
        . . .
        border-radius: 10px;
        overflow: hidden;  /* <- Add this line */
    }
    
    .main-image img {
        . . .
        /* border-top-right-radius: 10px; */
        /* border-top-left-radius: 10px; */
    }
    

I hope you find it useful! ๐Ÿ˜„ Above all, the solution you submitted is great!

Happy coding!

Marked as helpful

3

P
Julieโ€ข 130

@jclegg31

Posted

@MelvinAguilar thank you so much for the great tips and shortcuts! That's exactly the kind of stuff I'm looking for to try to improve! Appreciate it!

0

Please log in to post a comment

Log in with GitHub
Discord logo

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