-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image component with 'inline-block' adds text padding #18915
Comments
Temporary fix until vercel/next.js#18915 is resolved.
This mimics the default behavior of the Closing as a duplicate of #18637, please voice any new layout requests there! |
that is not resolving that issue |
Due to this behaviour, we are forced to add extra html tags to wrap around next/image causing an excessive DOM size. If possible, please look into this as it has become antithesis to what next.js is trying to achieve.
Issue #21914 describes this behaviour well. |
While this is true, we can add a |
@Timer how is this a duplicate of that other issue? And how is this anything like default when you can put any style on it you want. |
Only way I found to fix this is to force the height on the parent
|
As mentioned in the Next.js Doc (https://nextjs.org/docs/basic-features/image-optimization) "When using This solved the problem for me. |
Feedback we've received here:
|
It got changed to a span wrapper instead at some point. But here is the code we use to "fix" this issue (that should not be closed). .image-block-hack > span {
display: block !important;
}
.image-h-full-hack > span {
height: 100% !important;
} And it means for any image we need to be block or 100% height we have to wrap them with a div that uses one of these classes. And if we want other styles we will just have to keep adding these hacks. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
The new
<Image />
component in Next.js 10.0.1 hasdisplay
set toinline-block
which leads to what seems like extra margin on the bottom of the<div />
like so (see the red part):This is what that component (pictured above) looks like:
Pretty basic, but the
<Image />
component adds that bit of red margin. To fix this, I've followed some StackOverflow advice and added the following styles to the wrapper<div />
:To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
<Image />
component in any<div />
wrapper.<div />
wrapper (so you can see the "margin").Expected behavior
The Next.js image component is very opinionated when it comes to styling IMO (unlike other image optimization libraries I've used in the past). This is the first time (I think) that Next.js actually adds opinionated styling to an app which can get really annoying when those styles update and you've got to update all of your app's styling to work with the new Next.js
<Image />
component styles.IMO, the
<Image />
component should work out-of-box as a drop-in replacement for the HTML<img />
tag (i.e. the styling should behave in exactly the same way so existing styles work fine with it). When I started replacingimg
tags with the new<Image />
component, I had to update a bunch of my styling to work with the way Next.js styles that image (related to #18871). And then, I updated to Next.js 10.0.1 and all those styles broke again!I'm not exactly sure the best way to go about fixing this, but you definitely need to address those styling issues.
System information
The text was updated successfully, but these errors were encountered: