Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Product preview card component by HTML, CSS

SungKim96 30

@SungKim96

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I put the media query: @media only screen and (max-device-width: 480px) { img { width: 100%; height: auto; object-fit: cover; padding: 0; }

.box { display: inline; align-items: center; margin: 1rem; padding: 1px; }

.about-perfume { display: block; }

.perfume-name { font-size: 28px; }

.btn { width: 300px; height: 3rem; } } but it doesn't work :(

Community feedback

Jeck 1,080

@j-tomajin

Posted

Hello SumKim,

  • on the image you can do:
<picture>
<source media="(min-width: 780px)" srcset="images/image-product-desktop.jpg">     
<img src="images/image-product-mobile.jpg" alt="product-img">
</picture>

this will automatically switch the image with the given min-width on the <source> tag.

  • on the button, you don't have to give it a height, and just put a padding-block with a em so it will scale based on the parents font-size,
  • and make sure to use <div></div> when storing a lot of elements, not span...
  • on font-sizes you can use clamp values to automatically scale based on screen width, so you don't have to set another font-size on media query,
  • on the body do not use margins, just set it to:
body {
min-height: 100vh;
display: grid;
place-content: center;
}

to center the contents (or use flexbox)

Marked as helpful

0

SungKim96 30

@SungKim96

Posted

@j-tomajin Thank you for your helping :) I've never thought about the <picture> tag.

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord