Design comparison
Solution retrospective
Working through this project continued to engrain the Frontend Mentor process as well as further build upon my HTML & CSS skills.
I took to opportunity to implement CSS clamp(), which is a feature that I have struggled to wrap my head around. I also utilized transition for the hover effect.
I am proud that I caught the change in box shadow dimensions for the different screen sizes.
What challenges did you encounter, and how did you overcome them?CSS clamp() has been a feature that I have struggled with, but I did find an article that clarified a lot of the problems I was encountering. The article does have a tool to help calculate the growth value, but my math did match up!
What specific areas of your project would you like help with?General code structure and usage.
Community feedback
- @0xabdulkhaliqPosted 7 months ago
Hello there 👋. Congratulations on successfully completing the challenge! 🎉
- I have a suggestion regarding your code that I believe will be of great interest to you.
PREVENT LAYOUT SHIFTS 📉:
- Your solution needs to be improved to prevent Cumulative Layout Shift (CLS) which results a visually unstable or janky website, particularly on mobile devices.
- This can happen because of leaving the Image and/or video elements without adding explicit
width
andheight
attributes.
- The multimedia elements like
img
which aren't explicitly declared with height and width attributes are usually re-sized using CSS (either on the image itself or the parent container). When this happens, the browser can only determine their dimensions and allocate space for them once it starts downloading the 'unsized images' and/or videos.
- You may notice that when the browser fetches these images, your page content is constantly being pushed down or moved around from its original position (i.e., layout shifts) as the browser resizes the images and positions them on your page.
- Currently the
img
element have no explicitwidth
andheight
to prevent CLS,
<img src="assets/illustration-article.svg" alt="">
- Here's an example which could help you to prevent CLS,
<img src="assets/illustration-article.svg" alt="" width="336" height="201">
- The
height
andwidth
needs to have the actual measurements of that corresponding image, Additionally we provided emptyalt=""
because this svg is just used for decorative purposes.
- I would like to recommend the article Use explicit width and height on image elements from GTMetrix to learn more about Layout Shifts and why's it needs to be prevented.
.
I hope you find this helpful 😄 Above all, the solution you submitted is great !
Happy coding!
Marked as helpful0@nvallinePosted 7 months agoI know this is an issue when using Next.js, but I didn't realize it has also been adopted with using CSS. I haven't read the articles you provided yet, but is this now considered standard practice? @0xabdulkhalid
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