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
- Live Site URL: Click here
- Semantic HTML5 markup
- CSS (Custom Properties)
- Flexbox
- Mobile-first workflow
Manipulating an element using CSS custom properties was pretty exciting. I could easily change the background image for a div really easily. Custom properties are fun and can be used to solve tons of problems I could have used JavaScript to solve.
<div class="awesome"></div>
.awesome {
--bg-img: url("path to mobile image");
background-image: var(--bg-img);
}
@media (min-width: 760px) {
.awesome {
--bg-img: url("path to desktop image");
}
}
- Kevin Powell - Really helped shaped my understanding in modern CSS design. I would definetely recommend him to anyone who really wants to step up their CSS game.
- Frontend Mentor - @MartyOfMCA
- Twitter - @martyofmca