admin管理员组文章数量:1355542
I'm using Next.js 15 with Tailwind CSS V3 and the react-markdown package to render AI chat output inside a component.
I've customized the markdown rendering to replace all <h1>
, <h2>
, <h3>
elements with styled <div>
s using Tailwind classes to avoid default typography spacing issues.
Despite this, there’s still excessive vertical space between elements — particularly under h1
, h2
, and h3
replacements. I've tried removing all margin-bottom
and adding mb-0
, mt-0
, etc., but spacing persists.
Here’s what it looks like (I’ve added debug background colors and annotations):
✅ What I’m using:
- Next.js
15
- React
19
- ReactMarkdown
react-markdown@9
- Tailwind CSS
v3
- Plugins:
remark-gfm
rehype-highlight
✅ Expected result:
Minimal vertical spacing between elements in the chat bubbles.
❌ Actual result:
Headings and their following content have unwanted gaps that don’t collapse.
本文标签: cssWhy is there excessive spacing between elements in ReactMarkdown renderingStack Overflow
版权声明:本文标题:css - Why is there excessive spacing between elements in ReactMarkdown rendering? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743979053a2570998.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论