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

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

Cole Peterson

Director, Creative Technology for the Global Creative Data Group

7 个月

I come here every month to copy and paste this code. THX U!

要查看或添加评论,请登录

Edgar Hovhannisyan的更多文章

社区洞察

其他会员也浏览了