I'm leaning Next.js and I have found that next/image
is wrapping the img
with two spans and adding inline style to the img
tag which overriding my class style
How can I remove the inline style and the wrapper HTML tags like spans
and divs
?
My code looks like
import Image from 'next/image';
<Image className={'imgBack'} src={myImg} width="160" height="160" alt="" />
Result
<span style="box-sizing: border-box; display: inline-block; overflow: hidden; width: initial; height: initial; background: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;">
<span style="box-sizing: border-box; display: inline-block; overflow: hidden; width: initial; height: initial; background: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;">
<img alt="" src="/_next/image?url=%sq=75" decoding="async" data-nimg="intrinsic" class="imgBack" style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;" srcset="/_next/image?url=%2F_next%s;q=75 1x, /_next/image?url=%2F_next%s;q=75 2x">
</span>
<span>
Expected result
<img src="./myImg" class="imgBack" alt="" width="160" height="160" />
I have read the next/image
document and I couldn't find a way to fix that.