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 Challenge using Tailwind CSS

#tailwind-css
fsuropaty 160

@fsuropaty

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'm struggling on how to change the picture depending on the screen size, Does using the <picture> tag is the best way to change the image or are there any better methods to do this task?

Thank You

Community feedback

@freakyjones

Posted

Hi, fsuropaty,

congratulation on completing the challenge.

There is two way you can handle image responsiveness

  1. use it as a background image as per your code it will be like
#image-section{
  background-image:URL(image path);
  background-position:center;
  background-size:cover;
  background-repeat:no-repeat;
}

My solution also uses this method.

  1. The second method will be when we make img take a width of 100% so that it can inherit the parent container responsive property. The code will be something like
#imagesection{
  width: 10rem;
}
#imagesection img{
  width:100%
}

I hope this helps. Happy coding:)

Marked as helpful

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