Design comparison
Solution retrospective
I had issues with the hero image so I asked Chat-GPT and this code fixed my issues.
.overflow-wrapper { overflow-x: hidden; position: relative; }
serves two main purposes when dealing with a hero image that has negative margins:
-
Prevents Horizontal Scrollbars: By setting
overflow-x: hidden
, it hides any horizontal overflow content that might otherwise extend beyond the viewport. Negative margins on the hero image can push content outside the normal bounds of the page, which could cause unwanted horizontal scrollbars. This rule ensures that any content extending outside the viewport horizontally is clipped, avoiding those scrollbars. -
Maintains Positioning Context: By setting
position: relative
, you ensure that the.overflow-wrapper
creates a new containing block for absolutely positioned elements inside it (such as the hero image, if needed). This keeps the positioning of child elements relative to this wrapper, which helps prevent layout shifts or unexpected behavior caused by the negative margins of the hero image.
Together, these properties ensure that the layout remains visually contained without any unwanted overflow or positioning issues, making the design more robust and clean.
Community feedback
- @AdrianoEscarabotePosted about 1 month ago
Hi E. Marshall, hope you're doing well! I loved how your project turned out, but I’ve got a few suggestions that could be useful:
I noticed that your content is going to the side in higher resolutions, to solve this problem we can do the following:
body { min-height: 100vh; margin: 0 auto; }
The rest is fantastic.
Hopefully, you'll find it helpful. 👍
Marked as helpful0@CalderonVasquezPosted about 1 month ago@AdrianoEscarabote
I will give it a go. Thank you for the advice.
1
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