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

@m-rooeintan

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


What are you most proud of, and what would you do differently next time?

Nothing

What challenges did you encounter, and how did you overcome them?

To change product image from desktop mode to mobile mode, I use "background-image".

What specific areas of your project would you like help with?

Is there another way to change the image? I'm having trouble getting the links to display properly on GitHub. How to address so that images and fonts are loaded correctly in the live view? That is a big problem for me.

Community feedback

slack 120

@slackwaree

Posted

Hi, are you having trouble with changing the image when a certain viewport width is met? A simple way of doing this is by giving each img element an id, respective of their use case. Then in your CSS file, hide one of the elements using display: none, and create a media query to display that image when the viewport width is met. Also, make sure to hide the other image. Example:

HTML:

<img src="image/source" id="perfume-image-mobile">
<img src="image/source" id="perfume-image-desktop">

CSS:

#perfume-image-desktop {display:none}

@media only screen and (min-width: 769px) { /* Desktop styles */
    #perfume-image-mobile {display:none;}
    #perfume-image-desktop {display:/*block/grid/flex*/}
}
1

@m-rooeintan

Posted

Thank you for your help😊🌹@slackwaree

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