This is a solution to the Tip calculator app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the optimal layout for the app depending on their device's screen size
- See hover states for all interactive elements on the page
- Calculate the correct tip and total cost of the bill per person
- Solution URL: Solution URL
- Live Site URL: Live site URL
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Mobile-first workflow
- Vanilla JavaScript
I learnt many things while working on this project mostly with JavaScript. I learnt how to manipulate the HTML document by changing the content using JavaScript and how to change the style of the elements as well such as input fields and buttons when a condition is true.
peopleStyle.style.border = "none";
spanTitle.style.display = "none";
if (tipAmount === 0 || tipAmountPerPerson === Infinity) {
tipAmountValue.innerHTML = "Error"
totalValue.innerHTML = "Error"
peopleStyle.style.border = "2px solid red";
spanTitle.style.display = "initial";
}
I also learnt how to use CSS grid to style the layout of elements in a grid.
.buttons-grid-container {
display: grid;
grid-template-columns: auto auto;
}
.grid-item {
margin: 0.6rem 0.4rem;
}
- How to hide HTML5 number input's spin box - This helped me hide the number input's spin box.
- Styling elements with JavaScript - This is a good site that helped me finally understand how to style borders and any other property in general with JavaScript.
- Frontend Mentor - @ABQ4539