This is a solution to the Product preview card component 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 depending on their device's screen size
- See hover and focus states for interactive elements
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Mobile-first workflow
I learned that my semantic and accessibility HTML skills were lacking
If you notice my GitHub commit history for this project, you will find how I had to change all my HTML and CSS
I also had to struggle a lot with the picture
element which caused issues with alignment and making sure I used the correct CSS Grid concepts (for this project it seems to not be needed as much so I look forward to a future project that is more Grid heavy)
Concepts I learned:
- BEM style of naming CSS
- Accessibility in HTML and CSS (s tag, visually hidden classes, text before and after)
- CSS Grid concepts especially for alignment (justify/align of items/content)
<div class="product-card__prices">
<span class="product-card__new-price">$149.99</span>
<s class="product-card__old-price gray-text">$169.99</s>
</div>
/* screen reader accessibility text */
s::before {
content: " [strike-through start] ";
}
s::after {
content: " [strike-through end] ";
}
/* visually hiding accessibility text so only screen readers can find it */
s::before,
s::after {
clip-path: inset(100%);
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
width: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
}
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.
Note: Delete this note and the content within this section and replace with your own plans for continued development.
- The article that changed my life when creating this project - Everything you need + extra links are already in this.
- LinkedIn - Aldrin Sean Pereira
- Frontend Mentor - @AldrinSeanPereira
- Github - @AldrinSeanPereira
A huge THANK YOU! to the frontend mentor help section, Alex K Marshall and Grace Snow for their help.