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

Flexbox and boostrap

@Nondaba

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 encountered difficulty while I was applying media query for phone screen size, I did not know how to change the desktop design image to a mobile design image. Did I use the correct HTML mark up? Are my styles for elements suitable for phone screen size?

Community feedback

Aatypic 490

@Aatypic

Posted

Hello and congratulations on your solution I like it !

Concerning your questions.

-For you media I would change the breakpoint of max-width:375px to something bigger, because right now when the screen is 376px wide it's changing to the desktop image, and the device is still very small and hasn't changed really.

-You were close, you had your <picture> element already. You can in fact give multiple sources for different media screen sized in a <picture> tag. You need to add a second <source>, for something like this:

<picture>
  <source media="(max-width:768px)" srcset="images/image-mobile.jpg />
  <source media="(min-width:769px)" srcset="..."/>
  <img src="images/image-dekstop.jpg" alt="...">
</picture>

more info about <picture>

Good luck 🙂

Marked as helpful

1

@Nondaba

Posted

@Aatypic ,Thank you for the observation. Let me update my code so that it is correct.

0
Aatypic 490

@Aatypic

Posted

@Nondaba After checking I don't think you need 2 <source> 😅

The way you set it was right, just bigger breakpoints will help.

0

@Nondaba

Posted

@Aatypic ,😂 no worries. I am going to read up on break points.

0

@fico444

Posted

Hello, i solve that using background-image. in the @media code block just change the url of the background-image. If you want to use img tag on your html you have to use two, one with display: none (remains hidden) and other with display: inline-block. Then in the @media code block switch the values to display the correct image. Sorry for my english, I hope I could help you. ;)

Marked as helpful

1

@Nondaba

Posted

@fico444 ,thanks for the help. I used the picture element for changing the pictures . I will take your comment under advisement.

0

@RobicaCodeaza

Posted

Hello ! For media queries , you could just use the 'background' property and then set the url("/img/...yourImg) for changing the desktop image to mobile img that you have included in the files downloaded previously from frontendmentor.io .

Marked as helpful

1

@Nondaba

Posted

@RobicaCodeaza ,thank you for the insight. I used the picture element to accommodate for that.

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