Design comparison
Solution retrospective
Hello. I tried to make this project, but then I saw the content is cut off at the top when I adjust the screen for the mobile version. Can someone explain me what is wrong in my code cause I can't find the problem. Thank you!
Community feedback
- @danielmrz-devPosted 11 months ago
Hello @Goat3ggs!
Your project looks great!
The content is cut off at the top on mobile version because you set
place-content: center;
to it. This is not a problem for the destktop version, since the card should be in the middle of the page.You can fix that by adding
place-content: center;
only for the destktop version. You can use media queries for that. Do this:-
First, remove
place-content: center;
from the body. -
Then add
place-content: center;
to the body's @media: 600px.
By doing that, it'll only work for the desktop version, and your mobile version won't be cut off anymore.
I have one more suggestion for you:
- Consider increasing your @media breakpoint. Between 600px and 800px the card gets squeezed. Maybe increase it to 900px or so.
I hope it helps!
Other than that, you did a great job!
Marked as helpful1@Goat3ggsPosted 11 months ago@danielmrz-dev Thank you so much! I wouldn't have figured out the solution in a thousand years. I am at the beginning, so it is not so easy for me to find solutions for the problems I encounter. I fully appreciate your help.
1@danielmrz-devPosted 11 months ago@Goat3ggs
That's what we are here for! Help each other ๐ I'm glad I could help!
1 -
- @MelvinAguilarPosted 11 months ago
Hello!
The issue you're experiencing with the content being cut off at the top on mobile screens may be related to the way you've set the height of the
html
andbody
elements. While settingheight: 100%;
is a common practice and even comes by default in some CSS resets, on smaller screens like mobile devices, the content can often exceed 100% of the screen. Also, theplace-content: center;
is centering the element perfectly within its screen (That's why you will always see the SUVs section in the center.), but to achieve this, the component gets pushed upwards. This is why you may see content cut off at the top.To address this, consider using
min-height: 100vh;
instead. This allows the body element to grow in height, adapting to the content. You can also explore using dynamic viewport units for a responsive solution.I hope you find it useful! ๐
Happy coding!
Marked as helpful0@Goat3ggsPosted 11 months ago@MelvinAguilar Yes it is very useful and I appreciate that you had the time to help me. It is a solution that I wouldn't never thought of. Thank you!
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