Tip-Calculator With CSS Grid, CSS Flexbox, Vanilla Javascript
Design comparison
Solution retrospective
I think I did really good on this project. I had a very hard time trying to put dots inside the zeros and am not sure how to do it. Also, never figured out how to add colors to the dollar images on the right side of the app. This was my first time using Javascript but I feel like maybe I could have had a better solution with that. But out of all of this, the most important I want to know is how to make this compatible with mobile devices(which I know requires media screen with CSS). Any suggestions??
Community feedback
- @ZainMhrezPosted almost 3 years ago
Hi Larry, you did nice work. I think the process to calculate the tip and the total bill need some updates: the tip for each person = (bill_value * tip_percent) / people number. the total bill for each person = (bill_value + (bill_value * tip_percent)) / people number.
I wish this will help you, good luck.
0@ljcuttsPosted almost 3 years ago@ZainMhrez Thank you. I was a bit confused on what exactly I was calculating since both lines had "/person".
0 - @BenConfigPosted almost 3 years ago
The 'dots inside the zeros' are a feature of the Space Mono font family. It looks like you are using the Roboto font family which does not have the dots.
Why not just use the character '$' and then you can apply the
color
property?You should try building the page for mobile first. The mobile design is usually much simpler than the desktop design so it makes sense to start with that. You then apply media queries when you have more viewport space to work with.
0@ljcuttsPosted almost 3 years ago@BenConfig Thank you very much. I will make sure to work on the mobile design first then the desktop design on my next project.
0 - @nakoyawilsonPosted almost 3 years ago
The dots in the zeros are from the Space Mono font. Your import line for the Space Mono font is currently incomplete so it's not being imported properly. If you use the following import and change your ff-primary and ff-secondary to
'Space Mono', monospace;
the Space Mono font should work properly on your page.@import url("https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap");
0@nakoyawilsonPosted almost 3 years ago@ljcutts You're welcome. Also, for the dollar signs on the right the easiest way is to type the dollar sign instead of using the svg. But if you want to use the svg instead of including it in the html with an img tag you can use the svg tag and fill property. This page has code that changes the color of the svg on hover that you can use as reference: https://css-tricks.com/change-color-of-svg-on-hover/
Essentially you would just change the
fill="#9EBBBD"
part of the svg code for the dollar sign.<svg xmlns="http://www.w3.org/2000/svg" width="11" height="17"><path fill="#9EBBBD" d="M6.016 16.328v-1.464c1.232-.08 2.22-.444 2.964-1.092.744-.648 1.116-1.508 1.116-2.58v-.144c0-.992-.348-1.772-1.044-2.34-.696-.568-1.708-.932-3.036-1.092V4.184c.56.144 1.012.4 1.356.768.344.368.516.816.516 1.344v.288h1.824v-.432c0-.448-.088-.876-.264-1.284a3.783 3.783 0 00-.744-1.116A4.251 4.251 0 007.54 2.9a5.324 5.324 0 00-1.524-.492V.872H4.288V2.36a5.532 5.532 0 00-1.416.324c-.448.168-.84.392-1.176.672-.336.28-.604.616-.804 1.008-.2.392-.3.844-.3 1.356v.144c0 .96.316 1.708.948 2.244.632.536 1.548.884 2.748 1.044v3.912c-.704-.16-1.248-.472-1.632-.936-.384-.464-.576-1.08-.576-1.848v-.288H.256v.576c0 .464.08.924.24 1.38.16.456.404.88.732 1.272.328.392.744.728 1.248 1.008s1.108.476 1.812.588v1.512h1.728zM4.288 7.424c-.688-.128-1.164-.332-1.428-.612-.264-.28-.396-.644-.396-1.092 0-.464.176-.832.528-1.104.352-.272.784-.448 1.296-.528v3.336zm1.728 5.712V9.344c.768.128 1.328.328 1.68.6.352.272.528.688.528 1.248 0 .544-.196.984-.588 1.32-.392.336-.932.544-1.62.624z"/></svg>
Marked as helpful0
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