How to set the 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’ }}

/>

You can learn more by following my social media:

Support my blog by this link: https://buymeacoffee.com/edx126

Schedule a Call

Posted by Edgar Hovhannisyan

Comments

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