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 using html and css

Sekarsk18 180

@Sekarsk18

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

@RegexRiddler

Posted

Hi there, and good job on your submission! There is one thing I wish to point out in your code other than the slight size difference:

<div class="product-Image">
  <img src="Images/image-product-desktop.jpg" alt="DesktopImage" class="DesktopImage">
  <img src="Images/image-product-mobile.jpg" alt="MobileImage" class="MobileImage">
</div>

This works, but it makes the browser load both images regardless og screen size. What you could do instead is to only have one img tag in your html with the src attribute pointed to the most likely image that needs to be loaded, likely the mobile image, then you change the src content with your css like this.

<img src="Images/image-product-mobile.jpg" alt="perfume bottle laying between leaves" class="MobileImage">
@media (max-width: 375px) {
  .MobileImage {
    content: url(Images/image-product-mobile.jpg);
  }
}

Now when a user visits your website on mobile it only loads the mobile image but as soon as the viewport gets larger than 375px it will replace the image with the one ment for desktop.

Marked as helpful

0

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