Having some challenges while attempting to integrate the Next.js Image component into my React project alongside Tailwind CSS. Specifically, I'm facing issues with applying relative positioning and other styles like objectFit
. It seems that the root cause of this problem lies in the default container div
that Next.js generates around the img
tag. Below is the snippet of my current code:
<section style={{ position: 'relative', width: '100vw', height: '56.25vw', maxHeight: '500px' }}>
<Image
src={carouselItem.image}
alt={`Slide ${carouselItem.text}`}
layout="fill"
objectFit="cover"
className="object-cover object-center aspect-video"
/>
</section>