You want to set Next.js image width to 100% ?

It gives error when you want to set the Next.js width to 100% and fill the full height of its container.

For that use this code below in you image file, to avoid errors:

<Image

src={…}

width={0}

height={0}

sizes=”100vw”

style={{ width: ‘100%’, height: ‘auto’ }}

/>

And, of course, will appreciate supporting my blog by this link – https://www.buymeacoffee.com/edx126

Posted by Edgar Hovhannisyan

Comments

Your email address will not be published. Required fields are marked *