1

I'm giving height and width to a next image, and it doesn't set the height to what I'm telling it to set. It just sets the height to 100% and the widht works fine.

I'm using tailwind for the classes and the divs before do not have any other sizes that interfere with the image

<Image
  src={game.background_image}
  alt={game.slug}
  height="250"
  width="450"
  priority
  className="rounded-t-2xl"
/>

problem

EDIT: I had object-contain before in the classname but it didn't do anything

Igor Danchenko
  • 1,980
  • 1
  • 3
  • 13

1 Answers1

2

Wrap your in a div like so:

<div>
    <Image
        src={game.background_image}
        alt={game.slug}
        height="250"
        width="450"
        priority
        className=" rounded-t-2xl"
    />
</div>

This will make the height and width set inside the Next Image work as intended.

Newton Yuan
  • 148
  • 1
  • 17