Design comparison
Solution retrospective
Hello everyone.
This is my first challenge, I struggled a bit to center the whole content and I'm unsure if this is the correct way to center something inside the body tag.
Feel free to give me any feedback, I will appreciate it.
Community feedback
- @0xabdulkhaliqPosted over 1 year ago
Hello there π. Congratulations on successfully completing the challenge! π
- I have other recommendations regarding your code that I believe will be of great interest to you.
BODY MEASUREMENTS π:
- Use
min-height: 100vh
forbody
instead ofheight: 100vh
. Setting theheight: 100vh
may result in the component being cut off on smaller screens.
- For example; if we set
height: 100vh
then thebody
will have100vh
height no matter what. Even if the content spans more than100vh
of viewport.
- But if we set
min-height: 100vh
then thebody
will start at100vh
, if the content pushes thebody
beyond100vh
it will continue growing. However if you have content that takes less than100vh
it will still take100vh
in space.
.
I hope you find this helpful π Above all, the solution you submitted is great !
Happy coding!
Marked as helpful0@ledesmxPosted over 1 year agoHello Abdul Khalid,
Thank you for your valuable feedback, this is helpful for me.
0 - @josh76543210Posted over 1 year ago
Hi @AlbertoLed,
Great job on your solution!
Here are some recommendations for you (skip to the bottom if you just want the code π):
First of all, I would remove the
absolute
positioning of the attribution and also the fixedheight
of the body. These will cause problems for users viewing your page on smaller screens such as on a mobile phone.Next, add a
min-height
of 100vh to the body. This is to replace the height we removed earlier. Also, add aflex-direction
of column to position the attribution back underneath the container.Lastly, I suggest adding a
margin-top
of auto to the container and the attribution. This will make sure everything is centered nicely.Code to remove:
body { height: 100vh; } .attribution { position: absolute; bottom: 30px; }
Code to add:
body { flex-direction: column; min-height: 100vh; } .container { margin-top: auto } .attribution { margin-top: auto }
I hope this is helpful. Happy Coding!
Marked as helpful0@ledesmxPosted over 1 year agoHi Josh, Thanks for taking the time to give me feedback, I appreciate it.
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