Mobile-first | Grid and Flexbox | Stats preview card component
Design comparison
Solution retrospective
There is a breakpoint at 60rem
(960px
) switching from mobile to desktop version.
From 960px
and up to 988px
the image does not fit well in its parent .image-box
and a white space (with the violet background color of the parent box on top) below the image shows up.
How can I fix that?
Any help will be appreciated!
Community feedback
- @grace-snowPosted 9 months ago
I hope this is helpful
- Change sections to divs in this. You can add a section for the whole wrapper component inside main if you want, but the two halves should not be sections. A section would need a heading, not just an image.
- You should be including a modern css reset at the start of the styles in every project. Andy Bell has a good one you can look up and use. Get into that habit ASAP.
- The problem you are seeing with the image caused by missing object fit cover on the img element. You may need height and width 100% on desktop too.
- Try to avoid using complex css selectors like direct child selectors unless you have no choice. You want to keep css specificity as low as possible.
Marked as helpful1@dkaffesPosted 9 months agoThank you @grace-snow for your really helpful tips!
- Pretty useful!
- The (more) modern CSS reset by Andy Bell is very detailed and possibly not all parts are needed for the challenge? I will look into it in more detail.
- That solves the problem!
- Really useful tip. I will study more on the specificity subject!
Thank you for your time and effort!
0@grace-snowPosted 9 months ago@dkaffes don't mess around with resets, it's not worth it. Just include it all. It's actually WAY shorter than resets used to be!
1 - @Alokray007Posted 9 months ago
Hello there 👋
Good job on completing the challenge !
Your project looks really good!
I have a suggestion about your code that might interest you.
There is an very useful browser extension called Perfect Pixel that allow you compare with the design image and thus see the exact dimensions. I recommend it to you.
📌 Tags like <div> and <span> are typical examples of non-semantic HTML elements. They serve only as content holders but give no indication as to what type of content they contain or what role that content plays on the page. This tag change does not impact your project visually and makes your HTML code more semantic, improving SEO optimization as well as the accessibility of your project.
I hope this suggestion is useful for future projects.
Other than that, great job!
Happy coding.
0
Please log in to post a comment
Log in with GitHubJoin 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