Design comparison
Solution retrospective
Hello! I am submitting the solution for this challenge, I am not really sure about how I positioned the element in CSS but I was making some tests and looks good. Please, if you have any feedback you are welcome! Have a great day!
Community feedback
- @FluffyKasPosted over 2 years ago
Hey there,
The best way to center a component is using grid or flexbox (they can center things both horizontally and vertically pretty easily). You could add this to the
body
:display: grid
,place-items: center
,min-height: 100vh
.I'd also note some best practices missing here:
-
Use classes instead of IDs! Many times, you'll want to reuse the same styles for different elements which you can't do with IDs, as they are meant to be unique. There aren't many reasons to use IDs for styling to be honest, it's best to keep them to add some javascript (there can be exceptions of course, but as a rule of thumb use classes when you can).
-
There are way too many comments which makes it a bit hard to read your code. So unless you find them super useful, maybe use just a bit less!
-
You can remove the
height
from your container, it's not needed. Every element has their own height which is usually enough to work with! Setting an explicit height on things can easily cause an overflow. If the elements natural height isn't enough, you can add some padding! -
Remove the
br
element, it's not needed and it actually has a different meaning and use case. If you wanna add space, you can use padding or margin! ^^
I hope I was able to help a bit, if you got any questions, ask away ^^
Marked as helpful1@verdepedroPosted over 2 years agoHi @FluffyKas ! Thank you for all the input, is very useful! I will try to adapt the page to learn how to implement this. Have a wonderful day!
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