Next.js Image Component Not Displaying Correctly When Using CSS Grid with Auto Rows
I tried several approaches but none seem to work. I'm writing unit tests and I've searched everywhere and can't find a clear answer. I'm facing an issue where the Next.js Image component is not displaying images correctly when used inside a CSS Grid layout with auto rows. Despite setting the grid up properly, the images appear squished and do not maintain their aspect ratio. I've tried using the `layout='responsive'` prop, but it doesn't seem to help in this specific case. Here is my implementation: ```jsx import Image from 'next/image'; const Gallery = () => { return ( <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gridAutoRows: '200px', gap: '10px' }}> <div> <Image src="/images/photo1.jpg" alt="Photo 1" width={300} height={200} layout='responsive' /> </div> <div> <Image src="/images/photo2.jpg" alt="Photo 2" width={300} height={200} layout='responsive' /> </div> <div> <Image src="/images/photo3.jpg" alt="Photo 3" width={300} height={200} layout='responsive' /> </div> </div> ); }; export default Gallery; ``` When I check the browser's dev tools, the images are rendered with unusual dimensions, often getting clipped or not filling the grid cells as expected. The CSS grid layout itself seems to be working, as the grid lines are appearing correctly, but the images don't stretch to fill the allocated space properly. I've also experimented with different sizes for the `width` and `height` attributes, but the issue persists. I'm using Next.js version 12.0.7. Has anyone encountered a similar issue, or can someone suggest a way to fix this behavior? Any insights would be greatly appreciated! For context: I'm using Javascript on Linux. I'd really appreciate any guidance on this. How would you solve this? I'm working in a Debian environment. Is this even possible?