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
- Solution URL: solution URL
- Live Site URL: live site
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- Mobile-first workflow
To see how you can add media queries and create responsive design, see below:
@media only screen and (min-width: 1440px) {
.card {
width: 40vw;
}
.card .desktop-image {
display: block;
width: 50%;
height: auto;
}
.card .mobile-image {
display: none;
}
.content {
width: 50%;
}
}
@media only screen and (min-width: 1500px) {
.card {
width: 38%;
display: flex;
background-color: var(--white);
overflow: hidden;
border-radius: 15px;
}
.card .desktop-image {
display: block;
width: 50%;
height: auto;
}
.card .mobile-image {
display: none;
}
.content {
width: 50%;
}
}
@media only screen and (min-width: 1600px) {
.card {
width: 36%;
display: flex;
background-color: var(--white);
overflow: hidden;
border-radius: 15px;
}
.card .desktop-image {
display: block;
width: 50%;
height: auto;
}
.card .mobile-image {
display: none;
}
.content {
width: 50%;
}
}
@media only screen and (min-width: 1700px) {
.card {
width: 34%;
display: flex;
background-color: var(--white);
overflow: hidden;
border-radius: 15px;
}
.card .desktop-image {
display: block;
width: 50%;
height: auto;
}
.card .mobile-image {
display: none;
}
.content {
width: 50%;
}
}
@media only screen and (min-width: 1800px) {
.card {
width: 32%;
display: flex;
background-color: var(--white);
overflow: hidden;
border-radius: 15px;
}
.card .desktop-image {
display: block;
width: 50%;
height: auto;
}
.card .mobile-image {
display: none;
}
.content {
width: 50%;
}
}
@media only screen and (min-width: 1880px) {
.card {
width: 30%;
display: flex;
background-color: var(--white);
overflow: hidden;
border-radius: 15px;
}
.card .desktop-image {
display: block;
width: 50%;
height: auto;
}
.card .mobile-image {
display: none;
}
.content {
width: 50%;
}
}
If you want more help with writing markdown, we'd recommend checking out w3schools to learn more.
-My focus is still on responsive designs and creativity.
- W3Schools - This helped me for media queries and making the design responsive. I really liked this pattern and will use it going forward.
- Frontend Mentor - @irfan-hue
- LinkedIn - @raja-irfan-ahmed-203682217