Next.js Discord

Discord Forum

<Image /> component nightmare...

Answered
Pacific anchoveta posted this in #help-forum
Open in Discord
Avatar
Pacific anchovetaOP
Hi, everybody.

I have a hard time getting the Image component working as intended.

I want to restrict the heigh of an image to 40px, as I'm using it in a table row. Also, I need it to be object-fit: cover as I don't want it to be "skewed".

I tried to wrap the Image in a div with height: 40px, and then set fill and then style: {{object-fit: cover}}, but it does not work.

Could anyone give me a hint?
Answered by Pacific anchoveta
Problem solved by adding relative + height to the parent div.
Image
View full answer

4 Replies

Avatar
Giant panda
please share the code snippet
Avatar
Pacific anchovetaOP
Image
Avatar
Cape horse mackerel
Have you tried to add height={40} to the Image?
Avatar
Pacific anchovetaOP
Problem solved by adding relative + height to the parent div.
Image
Answer