Tip calculator solution with flexbox and vanillaJS
Design comparison
Community feedback
- @nelsonleonePosted almost 2 years ago
HELLO......congrats on completing this challenge ,well done 🎉 🎉
i noticed you had problem centering your content in the page .
you can use
body{ width:100vw; height: 100vh; display: flex; align-items: center; justify-content: center; }
Have fun coding 🎉 🎉 🎉
Marked as helpful0@WardronthewardenPosted almost 2 years ago@nelsonleone Thank you! Yeah, I always have a bit of a hassle with centering and need to play with flexbox quite a bit. I'll try it out as soon as I can!
Edit: I tried it out, works great! I did realize meanwhile that I just left in a temporary solution because I thought it was fine at the end of the day.
0 - @JanselLopezPosted almost 2 years ago
For center the calculator you can delete all margins in ".tipCalculator{}" and add these lines of code in your css file:
body { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; }
you can read about viewports(vw, vh) here => Viewport_concepts
Marked as helpful0@WardronthewardenPosted almost 2 years ago@JanselLopez Thank you, it works really well! Honestly as I was looking back at the project, I realized I just didn't really want to bother with centering the content when I started, so ended up with that weird temporary solution. Still, I did have some trouble with flexbox in the past, so I really appreciate it!
0@JanselLopezPosted almost 2 years ago@Wardronthewarden If you still give you any problem to work with FlexBox I recommend you finish these games that appearing in frontendmentor's interactive resources:
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