Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NextJS Image component not responding to my inline css inside it

Why isn't styling inside the Image component in NextJS not allowing me to manipulate my image. Am I missing something?

<Image className={styles.bg}
        style={{ transform: `translateY(${offset * 0.5}px)` }}
        src="/../public/bg.jpg"
        // width={2049}
        // height={2049}
        // objectFit="cover"
        layout="fill"
        quality={100}
      />
like image 445
AdamTzur Avatar asked Nov 20 '25 06:11

AdamTzur


1 Answers

If Next.js version is less than 12.1.1, this will not work. Onwards there is support for canonical style prop. With the style prop in support for props like layout, objectFit, and objectPosition is removed in Next.js 13.

like image 51
Tushar Shahi Avatar answered Nov 22 '25 22:11

Tushar Shahi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!