how to keep ratio of next image?
Unanswered
gref9730 posted this in #help-forum
gref9730OP
I need to specify parent div based o n how big the screen is and put inside a image and this image needs to try to fill the parent container but it needs to remain its aspectRatio how I do that with next/image? in nextjs14
<div className="w-[70vw] h-[80vh] relative">
<Image
fill={true}
src={srcSomething}
></Image>
</>
<div className="w-[70vw] h-[80vh] relative">
<Image
fill={true}
src={srcSomething}
></Image>
</>
2 Replies
Spectacled bear
Pass these classes to Image element
className="object-contain w-full h-full"
Spectacled bear
If this is resolved, mark it as answered.