This is a solution to the Age 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 an age in years, months, and days after submitting a valid date through the form
- Receive validation errors if:
- Any field is empty when the form is submitted
- The day number is not between 1-31
- The month number is not between 1-12
- The year is in the future
- The date is invalid e.g. 31/04/1991 (there are 30 days in April)
- View the optimal layout for the interface depending on their device's screen size
- See hover and focus states for all interactive elements on the page
- Solution URL: GitHub
- Live Site URL: vercel app
- Semantic HTML5 markup
- CSS custom properties
- CSS Grid
- Mobile-first workflow
I learned about gaps; they are used to add spaces between elements. I also learnt how to remove the scroll bar on an input type number HTML element.
- css gaps
<div class="inputs">
<div class="day-input">
<label>
<p class="label-text" id="day-label">Day</p>
<input type="number" id="day" placeholder="DD">
</label>
<p class="error" id="day-error" style="display: none">This field is required</p>
</div>
<div class="month-input">
<label>
<p class="label-text" id="month-label">Month</p>
<input type="number" id="month" placeholder="MM">
</label>
<p class="error" id="month-error" style="display: none"><small>This field is required</small></p>
</div>
<div class="year-input">
<label>
<p class="label-text" id="year-label">Year </p>
<input type="number" id="year" placeholder="YY">
</label>
<p class="error" id="year-error" style="display: none">This field is required</p>
</div>
</div>
<style>
.inputs{
display: flex;
flex-direction: row;
font-size: 15px;
gap: 20px;
}
</style>
- Removing scroll bar on html input type number element
<style>
.inputs input{
-moz-appearance: textfield;
} /*For chrome browser*/
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}/*for firefox browser*/
</style>
If you want more help with writing markdown, we'd recommend checking out The Markdown Guide to learn more.
Use this section to outline areas that you want to continue focusing on in future projects. These could be concepts you're still not completely comfortable with or techniques you found useful that you want to refine and perfect.
- openAI - This helped me in removing the HTML input type number scroll bar
- w3schools - This site acted as a refresher to me. I'd recommend it to anyone still learning this concept.
- Github - Simon Muchemi
- Frontend Mentor - @Simon-Muchemi
- Twitter - @SymonMuchemi
I would like to thank the frontend mentor community for the task. It has been fun coding and learning how to solve it.